2017-06-08 2 views
2

アイテムのサブアイテムから情報を取得し、アイテムの新しいフィールドに連結する計算フィールドがあります。Sitecore 8.2 Lucene検索で計算フィールド内のすべての用語のインデックスが作成されない

デバッガをステップ実行すると、計算されたフィールドが正しい情報を返すことがわかります。 Sitecoreによって生成されたインデックスをLukeを使用してチェックすると、計算されたフィールドが正しい値で表示されます。しかし、計算されたフィールド内の用語についてLuke(またはSitecore)で検索を実行すると、その用語を含むすべてのドキュメントが返されるとは限りません。

これは多言語バージョンのアイテムに関連している可能性があります。たとえば、項目の1つにオランダ語版とセルビア語(ラテン語版)があります。彼らは両方とも内容に「vooderlen」という言葉を含んでいます。しかし、私がその用語を検索すると、セルビアの文書だけが返されます。 "assisteert"を検索すると、両方の文書が返されます。なぜいくつかの用語が無視されているのか分かりません。私も次の検索設定を使用してい

public class ChildContent : AbstractComputedIndexField 
{ 
    public override object ComputeFieldValue(IIndexable indexable) 
    { 
     Assert.ArgumentNotNull(indexable, "indexable"); 
     Item item = indexable as SitecoreIndexableItem; 

     if (item == null) 
     { 
      return null; 
     } 

     // Only compute child content for Detail Layout templates 
     string detailLayoutTemplateId = Settings.GetSetting("DetailLayoutTemplateId"); 

     if (item.TemplateID.ToString() != detailLayoutTemplateId) 
     { 
      return null; 
     } 

     // Get Content Detail item 
     string contentDetailId = item["Content Detail"]; 
     var valueString = new StringBuilder(); 
     Item contentDetailItem; 
     string introContent, mainContent; 

     if (string.IsNullOrEmpty(contentDetailId)) 
     { 
      return null; 
     } 

     contentDetailItem = item.Database.GetItem(ID.Parse(contentDetailId), item.Language); 

     if (contentDetailItem == null) 
     { 
      return null; 
     } 

     // Concatenate intro and main content 
     introContent = contentDetailItem["Intro Content"]; 
     mainContent = contentDetailItem["Main Content"]; 

     if (!string.IsNullOrWhiteSpace(introContent)) 
     { 
      valueString.Append(Regex.Replace(introContent, "<.*?>", " ") + " "); 
     } 

     if (!string.IsNullOrWhiteSpace(mainContent)) 
     { 
      valueString.Append(Regex.Replace(mainContent, "<.*?>", " ") + " "); 
     } 

     return valueString.ToString(); 
    } 
} 

はここに関連するコードです。

<fieldMap type="Sitecore.ContentSearch.FieldMap, Sitecore.ContentSearch"> 
    <fieldNames hint="raw:AddFieldByFieldName"> 
     <field fieldName="_uniqueid" 
      storageType="YES" 
      indexType="TOKENIZED" 
      vectorType="NO" 
      boost="1f" 
      type="System.String" 
      settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider"> 
      <analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" /> 
     </field> 
     <field fieldName="childcontent" 
      storageType="YES" 
      indexType="TOKENIZED" 
      vectorType="NO" 
      boost="1f" 
      type="System.String" 
      settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider"> 
     </field> 
    </fieldNames> 
</fieldMap> 

<fields hint="raw:AddComputedIndexField"> 
    <field fieldName="childcontent">My.Namespace.ComputedFields.ChildContent, MyWebApp</field> 
</fields> 

答えて

1

ルークでDutchAnalyzerを使用した場合、オランダ語の結果をさらに得ることができました。残念ながら、Sitecoreはいくつかのアナライザを提供しているわけではなく、カスタムアナライザを作成しない限り、言語固有のものはありません。

これは私を適切な道に導き、必要な特定の言語の結果を得るためにさまざまな方法を検討しました。 CultureExecutionContextGetQueryableメソッドに渡すことで、私は期待した結果を得ることができました。

var queryable = context.GetQueryable<SearchResultItem>(
    new CultureExecutionContext(
     CultureInfo.GetCultureInfo(Sitecore.Context.Language.ToString()) 
    ) 
); 
関連する問題