Search code examples
luceneautosuggestsolr

Solr ShingleFilterFactory auto-suggest


I'm using Solr ShingleFilterFactory for auto-suggestion. This is my field configuration :

<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>

And my query :

q=rows=0&facet=true&facet.field=spellingShingle&facet.prefix=har

I get these answers :

  • harry potter
  • harrison ford
  • etc...

The problem is when I search "pot" or "for"... I'm not getting any results. I'd like to suggest "potter harry" or "ford harrison".

How can I do that?


Solution

  • I think, the results are depending on the content of your field spellingShingle. If both, "harry potter" and "potter harry" are values of the field, solr/lucene will return "potter harry" by typing "pot"