如何添加" NeverPublish"现场指向Sitecore的lucene指数?

时间:2016-04-25 07:07:09

标签: sitecore sitecore8 sitecore-lucene

我正在使用Sitecore 8上的一个小型后端应用程序。作为一项功能,应用程序必须快速搜索数千个项目并找到哪个项目不可发布。据我所知,我需要在lucene索引中添加相关字段。我对谷歌进行了一项研究,发现人们可以通过__Never publish字段访问此媒体资源。例如,他们在sitecore powershell上使用它来切换这个布尔属性(我试过它并且它可以工作)。

然而,我正在努力使这个工作在Lucene索引。我在master数据库中添加了类似这样的东西:

<configuration ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration">
          <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" />
              ... 
<field fieldName="__Never publish" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
</fieldNames>
</fieldMap>
</configuration>

我添加到索引的任何字段(甚至是一些内置字段)都可以编入索引,内容也可以存储。 (比如上面例子中的&#34;标题&#34;但我不明白为什么永远不会发布字段。

我查看了其他配置文件,发现它被排除在Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config内的索引之外,定义如下:

<exclude hint="list:ExcludeField"> .... <NeverPublish>{9135200A-5626-4DD8-AB9D-D665B8C11748}</NeverPublish> .... <exclude>

然后我评论了它但仍然没有运气。我想知道我是否正确引用了字段名称,或者我还有其他什么不应该。有什么建议吗?

1 个答案:

答案 0 :(得分:2)

This configuration works fine for me:

<field fieldName="__never publish" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.Boolean" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />

It differs from yours with type: type="System.Boolean"

p.s.: And of course excluding from search should be commented as you mentioned above