Search code examples
solrfacet

SOLR facet with prefix and filters


I have a problem with using facet.

I need autocomplete and for this I using 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

I am using facet because I need to add filters to query for example filter:("30") AND filter2:("1")

When I have in index a few documents all working fine and fast but if I add a lot of documents into index this query working too slow or simply SOLR is not responding at this query.

My 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"/>
....

Solution

  • I found the problem I simply added facet.method=enum and now it's work fine. Also I removed fq=filter:("30") AND filter2:("1") and place it in query, so... query now looks like this one:

    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