SOLR facet带有前缀和过滤器

时间:2012-03-23 09:36:49

标签: solr facet

我使用facet时遇到问题。

我需要自动完成功能,为此我使用了facet:

http://localhost:8080/solr/select?q=*:*&wt=json&indent=on&facet=on&rows=0&fq=filter:("30")  AND filter2:("1")&facet.field=spell&facet.prefix=g&facet.limit=10&facet.mincount=1

我正在使用facet因为我需要添加过滤器来查询例如 filter :(“30”)AND filter2 :(“1”)

当我在索引中有一些文档都工作得很好而且速度很快但是如果我在索引中添加了很多文档,那么这个查询工作太慢或者只是SOLR在这个查询中没有响应。

我的schema.xml:

......
<fieldType name="textSpellShingle" class="solr.TextField" positionIncrementGap="100">
   <analyzer>
      <tokenizer class="solr.StandardTokenizerFactory"/>
      <filter class="solr.LowerCaseFilterFactory"/>
      <filter class="solr.ShingleFilterFactory" maxShingleSize="4" outputUnigrams="true"/>
      <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
   </analyzer>
</fieldType>
.....
<fields>
   <field name="id" type="string" indexed="true" stored="true" required="true"/>
   <field name="article" type="textSpellShingle" indexed="true" stored="false" multiValued="true"/>
   <field name="title" type="text_general" indexed="true" stored="true"/>
   <field name="filter" type="int" indexed="true" stored="true"/>
   <field name="filter2" type="int" indexed="true" stored="true"/>
</fields>
<uniqueKey>id</uniqueKey>
<defaultSearchField>article</defaultSearchField>
<solrQueryParser defaultOperator="OR"/>
<copyField source="article" dest="spell"/>
<copyField source="title" dest="spell"/>
....

1 个答案:

答案 0 :(得分:3)

我发现问题我只是添加了facet.method = enum,现在它工作正常。我还删除了fq = filter :(“30”)AND filter2 :(“1”)并将其放入查询中,所以...查询现在看起来像这样:

http://localhost:8080/solr/select?q=filter:("30") AND filter2:("1")&wt=json&indent=on&facet=on&rows=0&facet.field=spell&facet.prefix=g&facet.limit=10&facet.mincount=1&facet.method=enum
相关问题