I've looked through a ton of examples and other questions here and from them, I've got my config very close to what I need but I'm missing one last little bit that I'm having a heck of a time working out. I'm searching on values like:
solar powered
solar glass
solar globe
solar lights
solar magic
solid brass
solid copper
What I want:
- If I search for
sol
the result should include all these values. This works. - If I search for
solar
I should get just the first five. This works. - If I search for
solar gl
I should get onlysolar glass
andsolar globe
. This does not work. Instead, I get one set of matches forsolar
and a second set of matches forgl
.
In a nutshell, I want to consider the input string as a whole, regardless of any whitespace. I gather this is accomplished by creating a separate query (versus index) analyzer, but I've not been able to make it work. Can anyone suggest a configuration that will get me what I'm looking for?
I've (unsuccessfully) tried:
- Querying with
"solar gl"
- Querying with
mm=100%
- Defining separate query and index analyzers both using KeywordTokenizerFactory. (Dunno what the heck I thought that would do.)
- Defining an index analyzer but not a query analyzer.
- Defining a query analyzer with no tokenizer.
Here's my current schema:
<field name="suggest_phrase" type="suggest_phrase"
indexed="true" stored="false" multiValued="false" />
And the field definition:
<fieldType name="suggest_phrase" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.KeywordTokenizerFactory" />
<filter class="solr.LowerCaseFilterFactory" />
</analyzer>
</fieldType>
And the config:
<searchComponent name="suggest_phrase" class="solr.SpellCheckComponent">
<lst name="spellchecker">
<str name="name">suggest_phrase</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.fst.FSTLookup</str>
<str name="field">suggest_phrase</str>
<str name="buildOnCommit">true</str>
</lst>
</searchComponent>
<requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/suggest_phrase">
<lst name="defaults">
<str name="spellcheck">true</str>
<str name="spellcheck.dictionary">suggest_phrase</str>
<str name="spellcheck.onlyMorePopular">true</str>
<str name="spellcheck.count">10</str>
<str name="spellcheck.collate">false</str>
</lst>
<arr name="components">
<str>suggest_phrase</str>
</arr>
</requestHandler>