Sitecore 8.1默认lucene。我使用带有计算字段的自定义索引来存储多列表字段的真实值,而不是guids。这有效,我可以在Luke工具中看到该字段被索引为文本。
某些值包含空格,但我希望将它们作为整个字段编入索引。问题是这些是以标记化的方式编制索引的,例如“小汉普顿”和“小汉普顿”等。被编入索引为“小'和'汉堡'
如何将计算字段存储为未加密存储?请参阅raw:AddComputedIndexField部分:
<indexConfigurations>
<myCustomIndexConfiguration type="Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider">
<indexAllFields>true</indexAllFields>
<initializeOnAdd>true</initializeOnAdd>
<analyzer ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration/analyzer" />
<fieldMap type="Sitecore.ContentSearch.FieldMap, Sitecore.ContentSearch">
<fieldNames hint="raw:AddFieldByFieldName">
<!-- you must have _uniqueid or you wont be able to update the document later -->
<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="title" storageType="YES" indexType="UNTOKENIZED" vectorType="YES" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
<field fieldName="summary" storageType="NO" indexType="TOKENIZED" vectorType="YES" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
</fieldNames>
</fieldMap>
<fields hint="raw:AddComputedIndexField">
<!-- resolves selected guids to text values -->
<field storageType="NO" indexType="UNTOKENIZED" fieldName="my multilist field">My.CoolStuff.Class, My.CoolStuff</field>
</fields>
我尝试过添加storageType =&#34; NO&#34; INDEXTYPE =&#34;非记号化&#34;在没有影响的情况下,它仍然被打包并存储。
答案 0 :(得分:1)
尝试将计算字段添加到计算字段的常规<fieldNames hint="raw:AddFieldByFieldName">
<field fieldName="my multilist field" 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>
</fieldNames>
部分,并指定分析器。
例如:
def ThreeHighestNumbers(arrayOfNumbers):
PmaxNum1 = 0
PmaxNum2 = 0
PmaxNum3 = 0
NMinNum1 = 0
NMinNum2 = 0
maxNumber = 0
for num in arrayOfNumbers:
if num < 0:
if num < NMinNum1:
NMinNum2 = NMinNum1
NMinNum1 = num
elif num < NMinNum2:
NMinNum2 = num
else:
if num > PmaxNum1:
PmaxNum3 = PmaxNum2
PmaxNum2 = PmaxNum1
PmaxNum1 = num
elif num > PmaxNum2:
PmaxNum3 = PmaxNum2
PmaxNum2 = num
elif num > PmaxNum3:
PmaxNum3 = num
maxNumber = PmaxNum1 * PmaxNum2 * PmaxNum3
if maxNumber == 0:
return []
if maxNumber < PmaxNum1 * NMinNum1 * NMinNum2:
return [PmaxNum1,NMinNum2,NMinNum1]
else:
return [PmaxNum1,PmaxNum2,PmaxNum3]
arraOfNumbers = [1,2,3,4,5,6,-8,-9,0]
print ThreeHighestNumbers(arraOfNumbers)
答案 1 :(得分:-1)
我可以为你推荐一件事,它应该有效:
创建一个计算字段,用&#34;替换title字段中的空格。 _&#34;,当您搜索时,用&#34;替换搜索关键字中的任何空格。 _&#34;所以你会这样:Little_Hampton