创建构面值列表时,我的架构中有以下内容:
<field name="contract_facet_sector_ids" type="text" indexed="true" stored="true" multiValued="true" required="false" />
我想要存储的facet是“1_1”,“2_43”,“2_99”等字符串。但是,当我查看facet计数返回的数据时,下划线似乎已被删除:
[facet_fields] => Array
(
[contract_facet_sector_ids] => Array
(
[11] => 0
[243] => 0
[299] => 0
有人可以帮我解决我这里出错的地方吗? “文本”字段类型的定义如下:
<fieldType name="text" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory" />
<filter class="solr.StopFilterFactory"
ignoreCase="true" words="stopwords.txt"
enablePositionIncrements="true" />
<filter class="solr.WordDelimiterFilterFactory"
generateWordParts="1" generateNumberParts="1"
catenateWords="1" catenateNumbers="1"
catenateAll="0" splitOnCaseChange="1" />
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt" />
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory" />
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true" />
<filter class="solr.StopFilterFactory"
ignoreCase="true" words="stopwords.txt"
enablePositionIncrements="true" />
<filter class="solr.WordDelimiterFilterFactory"
generateWordParts="1" generateNumberParts="1"
catenateWords="0" catenateNumbers="0"
catenateAll="0" splitOnCaseChange="1" />
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt" />
</analyzer>
</fieldType>
非常感谢!
塞布
最佳答案
WordDelimiterFilterFactory导致你的下划线被删除。基于以下内容:
Splits words into subwords and performs optional transformations on subword groups. By default, words are split into subwords with the following rules:
split on intra-word delimiters (all non alpha-numeric characters). "Wi-Fi" -> "Wi", "Fi"
...
基于您如何使用此字段的描述 - “我想要存储的方面是字符串...”。我建议您使用下面定义的 string
的 fieldType(来自 Solr 示例),除非您确实需要应用其他分析器。
<!-- The StrField type is not analyzed, but indexed/stored verbatim. -->
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
关于string - Solr:方面计数索引不能是字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8806093/