Solr SpellCheker configuration for multiple fields same time
My advanced search option allows users to search for three different fields same time. The fields are - first name, last name and org name. Now I have to add spell checking feature for the fields. When wrong spelling is entered for each of these words like first name: jahn, last name: smath, org and org name: bpple the search result should return a suggestion like (collation) firstname:john AND lastname:smith AND orgname: apple What is the best approach to implement spell checking for these three different fields: 1. Build a single directory for all fields by copying them into a 'spell' field as: schema.xml configuration solrconfig.xml configuration textSpell default spell ./spellchecker Now the queries: 1a. /select?q=FIRST_NAME:jahn&LAST_NAME:smath&ORG_NAME:bpple&spellcheck=true The spell check searches against the dictionary './spllechecker' returns the suggestions as FIRST_NAME:john, LAST_NAME:smath and ORG_NAME:apple. Works as expected. 1b. /select?q=LAST_NAME:jahn&spellcheck=true The spell check searches against the dictionary './spllechecker' returns the suggestions for LAST_NAME as 'john' But there is no last name 'john' for the field LAST_NAME. So the sub sequent search returns NO results, which is not accepted. So, this approach seems to be wrong for me.. 2. Build a separate directory for each field. schema.xml configuration solrconfig.xml configuration textSpell firstname spell_fname ./fname_spellchecker lastname spell_lname ./lname_spellchecker oname spell_org_name ./orgname_spellchecker Now the queries: 1a. /select?q=FIRST_NAME:jahn&LAST_NAME:smath&ORG_NAME:bpple&spellcheck=true How can I mention in the query to search against different dictionaries for different fields like FIRST_NAME in fname_spellchecker, LAST_NAME in lname_spellchecker and ORG_NAME in orgname_spellchecker? Or can I make the spell checker to store the field names and its values. Please discuss my approaches and suggest a solution?
Re: Solr SpellCheker configuration for multiple fields same time
Hmm, I don't think there is currently a solution for this. #1 is not viable for the reasons you mentioned and #2 is not supported by the current code. That being said, I think it wouldn't be too hard to for someone to work up a patch for this. Essentially, we need the ability to add in per dictionary queries and then be able to route them to each dictionary. If you feel up to this, I can take a look at your patch, if not at least open a JIRA issue for it so someone else might take it up. Unfortunately, I don't have the time right at the moment, but maybe in a few weeks. -Grant On Mar 17, 2009, at 3:40 PM, Shyamsunder Reddy wrote: My advanced search option allows users to search for three different fields same time. The fields are - first name, last name and org name. Now I have to add spell checking feature for the fields. When wrong spelling is entered for each of these words like first name: jahn, last name: smath, org and org name: bpple the search result should return a suggestion like (collation) firstname:john AND lastname:smith AND orgname: apple What is the best approach to implement spell checking for these three different fields: 1. Build a single directory for all fields by copying them into a 'spell' field as: schema.xml configuration positionIncrementGap="100" > stored="true"/> required="true"/> stored="true" multiValued="true"/> solrconfig.xml configuration class="solr.SpellCheckComponent"> textSpell default spell ./spellchecker Now the queries: 1a. /select? q=FIRST_NAME:jahn&LAST_NAME:smath&ORG_NAME:bpple&spellcheck=true The spell check searches against the dictionary './spllechecker' returns the suggestions as FIRST_NAME:john, LAST_NAME:smath and ORG_NAME:apple. Works as expected. 1b. /select?q=LAST_NAME:jahn&spellcheck=true The spell check searches against the dictionary './spllechecker' returns the suggestions for LAST_NAME as 'john' But there is no last name 'john' for the field LAST_NAME. So the sub sequent search returns NO results, which is not accepted. So, this approach seems to be wrong for me.. 2. Build a separate directory for each field. schema.xml configuration positionIncrementGap="100" > stored="true"/> required="true"/> stored="true" multiValued="true"/> stored="true" multiValued="true"/> stored="true" multiValued="true"/> solrconfig.xml configuration class="solr.SpellCheckComponent"> textSpell firstname spell_fname ./fname_spellchecker lastname spell_lname ./lname_spellchecker oname spell_org_name ./orgname_spellchecker Now the queries: 1a. /select? q=FIRST_NAME:jahn&LAST_NAME:smath&ORG_NAME:bpple&spellcheck=true How can I mention in the query to search against different dictionaries for different fields like FIRST_NAME in fname_spellchecker, LAST_NAME in lname_spellchecker and ORG_NAME in orgname_spellchecker? Or can I make the spell checker to store the field names and its values. Please discuss my approaches and suggest a solution?
Re: Solr SpellCheker configuration for multiple fields same time
Yes, approach #2 will certainly be useful. I'll open an issue. On Wed, Mar 18, 2009 at 6:20 PM, Grant Ingersoll wrote: > Hmm, I don't think there is currently a solution for this. #1 is not > viable for the reasons you mentioned and #2 is not supported by the current > code. That being said, I think it wouldn't be too hard to for someone to > work up a patch for this. Essentially, we need the ability to add in per > dictionary queries and then be able to route them to each dictionary. If > you feel up to this, I can take a look at your patch, if not at least open a > JIRA issue for it so someone else might take it up. Unfortunately, I don't > have the time right at the moment, but maybe in a few weeks. > > -Grant > > > On Mar 17, 2009, at 3:40 PM, Shyamsunder Reddy wrote: > > My advanced search option allows users to search for three different >> fields same time. >> The fields are - first name, last name and org name. Now I have to add >> spell checking feature for the fields. >> >> When wrong spelling is entered for each of these words like first name: >> jahn, last name: smath, org and org name: bpple >> >> the search result should return a suggestion like (collation) >> firstname:john AND lastname:smith AND orgname: apple >> >> >> What is the best approach to implement spell checking for these three >> different fields: >> >> 1. Build a single directory for all fields by copying them into a 'spell' >> field as: >>schema.xml configuration >> >>> positionIncrementGap="100" > >> >> >> >> >> >> >> >> >> > required="true"/> >>> multiValued="true"/> >> >> >> >> >> >>solrconfig.xml configuration >> >>textSpell >> >> default >> spell >> ./spellchecker >> >> >> >> Now the queries: >> 1a. >> /select?q=FIRST_NAME:jahn&LAST_NAME:smath&ORG_NAME:bpple&spellcheck=true >> >> The spell check searches against the dictionary './spllechecker' returns >> the suggestions as >> FIRST_NAME:john, LAST_NAME:smath and ORG_NAME:apple. Works as expected. >> >> 1b. /select?q=LAST_NAME:jahn&spellcheck=true >> The spell check searches against the dictionary './spllechecker' returns >> the suggestions for LAST_NAME as 'john' >> But there is no last name 'john' for the field LAST_NAME. So the sub >> sequent search returns NO results, which is not accepted. >> >> So, this approach seems to be wrong for me.. >> >> 2. Build a separate directory for each field. >>schema.xml configuration >> >>> positionIncrementGap="100" > >> >> >> >> >> >> >> >> >> > required="true"/> >>> multiValued="true"/> >>> multiValued="true"/> >>> stored="true" multiValued="true"/> >> >> >> >> >> >>solrconfig.xml configuration >> >>textSpell >> >> firstname >> spell_fname >> ./fname_spellchecker >> >> >> lastname >> spell_lname >> ./lname_spellchecker >> >> >> oname >> spell_org_name >> ./orgname_spellchecker >> >> >> >> Now the queries: >> 1a. >> /select?q=FIRST_NAME:jahn&LAST_NAME:smath&ORG_NAME:bpple&spellcheck=true >> >> How can I mention in the query to search against different dictionaries >> for different fields like >> FIRST_NAME in fname_spellchecker, LAST_NAME in lname_spellchecker and >> ORG_NAME in orgname_spellchecker? >> >> Or can I make the spell checker to store the field names and its values. >> >> Please discuss my approaches and suggest a solution? >> >> >> >> > -- Regards, Shalin Shekhar Mangar.