2016-03-01 48 views
0

我正在使用Sitecore 7.2。我创建了一个自定义的Lucene索引。未从Lucene索引获取类型Droplist和TreeList的字段值

虽然我能够得到Single-line Text类型的字段的值,Rich Text & DateTime,我没有得到的类型,如DroplistTreeList字段的值。

我已经尝试将这些字段的indexType更改为“UNTOKENISED”,但仍然继续出现此问题。我还使用Luke检查了我的索引,并观察到只有标题,摘要和正文字段是索引的一部分。

下面是我在我的字段中定义的索引配置部分。 productstype分别是TreelistDroplist字段。

<fieldMap type="Sitecore.ContentSearch.FieldMap, Sitecore.ContentSearch"> 
    <fieldNames hint="raw:AddFieldByFieldName"> 
    <field fieldName="title" 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="summary" 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="body" 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="datemodified" 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="products" 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> 
    <fieldType fieldName="type" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" 
     settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" /> 
    </fieldNames> 
</fieldMap> 

我使用从索引中取值的类是如下:

public class DownloadResult : SearchResultItem 
    { 
     [IndexField("title")] 
     public string Title { get; set; } 

     [IndexField("summary")] 
     public string Summary { get; set; } 

     [IndexField("type")] 
     public string Type { get; set; } 

     [IndexField("body")] 
     public string Body { get; set; } 

     [IndexField("datemodified")] 
     public DateTime DateModified { get; set; } 

     [indexfield("products")] 
     public string products { get; set; }   
    } 
+0

什么是你正在使用的搜索类是什么样子? –

+0

当你在卢克看场时,它有价值吗? –

+0

@dnstommy是的。当我将类型更改为单行文本并重建索引时,会返回值。 – Sairaj

回答

0

请检查您搜索的默认配置文件域类型“DropList”和“的TreeList”。如果它没有添加请添加它:它会是这个样子:

<fieldTypes hint="raw:AddFieldTypes"> 
… 
<fieldType name="droplist" storageType="NO" indexType="TOKENIZED" vectorType="NO" boost="1f" /> 
<fieldType name="treelist" storageType="NO" indexType="TOKENIZED" vectorType="NO" boost="1f" /> 
… 
</fieldTypes> 
+0

我默认的Lucene索引配置已经有DropList和TreeList的字段类型 – Sairaj

0

在文件Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config

你需要有索引droplist未来fieldReaders,树形列表等。 这些都是在Sitecore的默认配置:

  <fieldReader fieldTypeName="checklist|multilist|treelist|treelistex|tree list" fieldNameFormat="{0}" fieldReaderType="Sitecore.ContentSearch.FieldReaders.MultiListFieldReader, Sitecore.ContentSearch" /> 
     <fieldReader fieldTypeName="icon|droplist|grouped droplist"      fieldNameFormat="{0}" fieldReaderType="Sitecore.ContentSearch.FieldReaders.DefaultFieldReader, Sitecore.ContentSearch" /> 
     <fieldReader fieldTypeName="name lookup value list|name value list"    fieldNameFormat="{0}" fieldReaderType="Sitecore.ContentSearch.FieldReaders.NameValueListFieldReader, Sitecore.ContentSearch" /> 
     <fieldReader fieldTypeName="droplink|droptree|grouped droplink|tree"   fieldNameFormat="{0}" fieldReaderType="Sitecore.ContentSearch.FieldReaders.LookupFieldReader, Sitecore.ContentSearch" /> 

,请检查您是否有这些配置,如果你引用这个配置文件到您的自定义索引文件。

+0

是的,我在Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config中有这些配置。 – Sairaj

0

尝试宣告你的领域,如此,总是对我的作品:

[IndexField("products")] 
public IEnumerable<ID> Products { get; set; } 

[IndexField("type")] 
public IEnumerable<ID> Type { get; set; } 

您也可以尝试在AddFieldByFieldTypeName设置调整的存储类型设置

<fieldType fieldTypeName="droptree" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" /> 
+0

我已经使用Luke检查了我的索引,并观察到只有标题,摘要和正文字段是索引的一部分。因此这不是模型的问题。产品和类型字段不会添加到索引本身。 – Sairaj

+0

好的,通过查看顶部的术语而不是搜索屏幕来检查它是否在索引中。如果没有,我还建议上面在'AddFieldByFieldTypeName'设置和'AddFieldByFieldName'设置中将'storageType'更改为yes。如果这没有帮助,那么客户导致问题。 –

+0

对不起Typo *自定义。 –

0

你应该使用计算索引字段获取这些字段(Treelist和Droplist)索引。 参考指南:How to Add Computed Index

0

在尝试完所有不同的建议并输入空白后,我在配置中将indexAllFields的值更改为true。这解决了它。

0

(不能在Sairaj的答案评论)

虽然indexAllFields解决这是不理想的。我假设的真正问题(因为它发生在我们身上)是你试图索引一个字段,它的值是从标准值中提取的。在内容编辑器中查看项目时,它看起来有一个值,但是根据Lucene(不要问我为什么)它没有值。

显然Lucene不会从标准值中读取字段值,除非您将其告知indexAllFields。虽然自定义字段也可以用来解决这个问题,但我觉得这可能是A)Sitecore中的一个错误,或者B)一个没有人能够追踪的配置选项。

(编辑)

我们注意到了这个在8.1