我在SOLR中创建了以下类型的模式,用于索引“Age High”和“Age Low”字段
<field name="age" type="age-levels-facet" multiValued="true" indexed="true" stored="true" />
<fieldtype name="age-levels-facet" class="solr.TextField">
<analyzer>
<tokenizer class="solr.PatternTokenizerFactory" pattern=";"/>
<filter class="solr.PatternReplaceFilterFactory" pattern="^(([0-2]))?$" replacement="Birth-2" replace="all" />
<filter class="solr.PatternReplaceFilterFactory" pattern="^(([3-5]))?$" replacement="3-5" replace="all" />
<filter class="solr.PatternReplaceFilterFactory" pattern="^(([6-8]))?$" replacement="6-8" replace="all" />
<filter class="solr.PatternReplaceFilterFactory" pattern="^(([9]|1[0-2]))?$" replacement="9-12" replace="all" />
<filter class="solr.PatternReplaceFilterFactory" pattern="^((1[3-9]|[2-9][0-9]))?$" replacement="13+" replace="all" />
</analyzer>
</fieldtype>
所以如果,我通过“年龄= 4-12”,它将返回我的结果如下。
Birth-2 (0)
3-5 (1)
6-8 (0)
9-12 (1)
13+(0)
根据我创建的模式,这是正确的。但逻辑上不正确。例如对于年龄组为4-12的用户,结果为
Birth-2 (0)
3-5 (1)
6-8 (1)
9-12 (1)
13+(0)
任何人都有任何想法,我如何才能实现这一点,使用solr ????