2015-01-23 2 views
3

키워드 토크 나이저에 대해 SOLR을 사용하는 동안 sitecore 색인 구성의 예가 있습니까? 다중 단어 문자열이있는 필드에서 패싯을 만들려고하지만 현재 반환되는 패싯은 필드의 단어와 패싯을 반환하는 것입니다.SOLR을 사용하는 문구에 Sitecore faceting

예 : 저는 주 (state)를위한 필드가있는 항목을 가지고 있으며, 뉴햄프셔 (South Dakota)와 같은 값을 가진 주 필드를 보려고합니다. 는하지만 결과에서, 나는

이름 = 새, 집계 = XX
이름 = 햄프셔, 집계 = XX
이름 = 남, 집계 = XX
이름 = 다코타, 집계 = XX

을 함께 패싯 값을 가져

누구나 올바른 설정을 변경해 주시겠습니까?

이 내 현재의 구성입니다 :

당신은 다음 방법 중 하나를 사용하여이를 달성 할 수
 <index id="site_search_web_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider"> 
     <param desc="name">$(id)</param> 
     <param desc="core">site_search_web</param> 
     <param desc="propertyStore" ref="contentSearch/databasePropertyStore" param1="$(id)" /> 
     <strategies hint="list:AddStrategy"> 
      <strategy ref="contentSearch/indexUpdateStrategies/onPublishEndAsync" /> 
     </strategies> 

     <locations hint="list:AddCrawler"> 
      <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch"> 
      <Database>web</Database> 
      <Root>/sitecore/content/Home</Root> 
      </crawler> 
     </locations> 
     </index> 
+0

당신은 토크 나이와 텍스트 형식을 사용하는 대신 할 문자열 필드의 유형을 변경할 수 있습니다. 토큰 화 도구는 공백, 하이픈 등과 같은 토큰 경계에서 텍스트를 분리하므로 패싯에서 개별 토큰을 볼 수 있습니다. – arun

+0

필드 수준 대신 인덱스 수준에서이 작업을 수행 할 수 있습니까? 이 경우 샘플 구성을 정말 고맙게 생각합니다! 감사! – aceanindita

+0

필자는 필드 레벨에 고정되어 있다고 생각하지만 계산 된 필드를 사용하거나 다른 필드에 별칭을 선언하고 특별한 경우 대신 사용할 수 있습니다. –

답변

4

:

해결 방법 1

당신은 반환하는 계산 된 필드를 만들 수 있습니다 패싯 값을 계산하고 토큰 화를 피하기 위해 계산 된 필드 유형을 "문자열"로 설정하십시오. 귀하의 계산 된 필드가 같아야 다음과 같이 Sitecore.ContentSearch.Solr.Indexes.config에 계산 필드를

public class TitleComputedField : IComputedIndexField 
{ 
    public object ComputeFieldValue(IIndexable indexable) 
    { 
     if (indexable == null) throw new ArgumentNullException("indexable"); 
     var scIndexable = indexable as SitecoreIndexableItem; 

     if (scIndexable == null) 
     { 
      Log.Warn(
       this + " : unsupported IIndexable type : " + indexable.GetType(), this); 
      return false; 
     } 

     var item = (Item)scIndexable; 
     if (item == null) 
     { 
      Log.Warn(
       this + " : unsupported SitecoreIndexableItem type : " + scIndexable.GetType(), this); 
      return false; 
     } 

     if (String.Compare(item.Database.Name, "core", StringComparison.OrdinalIgnoreCase) == 0) 
     { 
      return false; 
     } 

     return = item.Fields["Title"]; 
    } 

    public string FieldName { get; set; } 
    public string ReturnType { get; set; } 
} 

그리고 구성 :

 <fields hint="raw:AddComputedIndexField"> 
     ... 
     <field fieldName="plaintitle"    returnType="string">YourNamespace.TitleComputedField, YourAssembly</field> 
     </fields> 

을 그리고 마지막으로 당신은 "plaintitle"에 패싯 경우 필드에서 예상되는 결과를 얻어야합니다.

당신은 다음과 같이 SOLR의의 schema.xml을 업데이트하여 색인 수준에서 필드를 만들 수 2

솔루션 :

유형 문자열의 SOLR에 새 필드를 작성

<fields> 
    ... 
    <field name="plaintitle" type="string" indexed="true" stored="true" /> 
</fields> 

을 입력 한 다음 원래 필드를 새 필드에 복사하려면 "copyfield"를 만듭니다.

다음 코드를 사용하여 새로운 분야에 패싯 수있는 두 솔루션의
<copyField source="title_t" dest="plaintitle" /> 

:

query.FacetOn(i => i["plaintitle"]);