msayef
msayef

Reputation: 73

Phrase matching from paragraph using Solr

I have a doc/list of names of countries.

id:countries name:[Belize, Benin, Bhutan, Bolivia, Bosnia, Bosnia Herzegovina, Botswana, Brazil, Brunei]

If my query is "I live in Bosnia Herzegovina", or more generally " * Bosnia Herzegovina *", Then I would like to see countries as query result.

I could only manage single word countries. Could anyone help me to solve this issue? Thanks in advance.

EDITED:

Here is my schema configuration for the field. <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100"> <analyzer type="index"> <tokenizer class="solr.KeywordTokenizerFactory"/> <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" /> <filter class="solr.LowerCaseFilterFactory"/> </analyzer> <analyzer type="query"> <tokenizer class="solr.KeywordTokenizerFactory"/> <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" /> <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> <filter class="solr.LowerCaseFilterFactory"/> </analyzer> </fieldType> And I am searching like this: http://localhost:8983/solr/core/select?q=i love Bosnia Herzegovina&wt=json

Upvotes: 1

Views: 106

Answers (1)

msayef
msayef

Reputation: 73

I solved the problem. Actually the problem was in the search query. We have to embed the query with a pair of first bracket. This will solve the problem.

Before: http://localhost:8983/solr/core/select?q=i love Bosnia Herzegovina&wt=json

Solved: http://localhost:8983/solr/core/select?q=(i love Bosnia Herzegovina)&wt=json

Upvotes: 1

Related Questions