I am using the solr suggestion component with the following configuration:
schema.xml
<fieldType name="textSpell" class="solr.TextField">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<field name="image_memo" type="text_general"/>
<field name="username" type="text_general"/>
<field name="image_memo" type="text_general"/>
<field name="image_text" type="text_general"/>
<!-- More fields included here -->
<field name="spell" type="textSpell" indexed="true" stored="true" multiValued="true"/>
<copyField source="*" dest="spell"/>
solrconfig.xml
<searchComponent class="solr.SpellCheckComponent" name="suggest">
<lst name="spellchecker">
<str name="name">suggest</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>
<str name="field">spell</str>
<str name="buildOnCommit">true</str>
</lst>
</searchComponent>
<requestHandler class="org.apache.solr.handler.component.SearchHandler"
name="/suggest">
<lst name="defaults">
<str name="spellcheck">true</str>
<str name="spellcheck.dictionary">suggest</str>
<str name="spellcheck.onlyMorePopular">true</str>
<str name="spellcheck.count">6</str>
<str name="spellcheck.collate">true</str>
<str name="spellcheck.collateExtendedResults">true</str>
<str name="spellcheck.collate">true</str>
<str name="spellcheck.maxCollations">6</str>
<str name="spellcheck.maxCollationTries">1000</str>
<str name="spellcheck.extendedResults">true</str>
<str name="spellcheck.collateParam.mm">100%</str>
</lst>
<arr name="components">
<str>suggest</str>
<str>query</str>
</arr>
</requestHandler>
As you can see there is a field spell
wich i am using for a suggestion queries.
This works great even for multiple term queries.
But what I need is to search on selected fields only.
So for example I want valid suggestions only for the fields image_memo
and username
The user can dynamicly add and remove fields to search.
I know that I could do something like this:
q=(image_memo:*search* OR image_username:*search*)
But this is is slowing down dramtically if you got a lot of fields and a multiple term query.
Example: Searching in Field memo, username, field, field1 and field2
for term, term1 and term2.
((memo:term OR username:term OR field:term OR field1:term OR field2:term) AND (memo:term1 OR username:term1 OR field:term1 OR field1:term1 OR field2:term1) AND (memo:term2 OR username:term2 OR field:term2 OR field1:term2 OR field2:term2))
Is there any way to dynamically select the spell
fields. Or is there a way that I can search for specific fields only in a multivalued field
I am using Apach Solr 4 Alpha.