0

I have a document with persons name and I would like to return those document based on partial names, for example:

Querying: "Joseph Gar*"

Should return

Joseph Garret
Joseph Garnier

How to make that query using solr?

I have tried:

q=complete_name:"Joseph Gar*"
q=complete_name:"Joseph Gar"~5
q=complete_name:(Joseph AND Gar)
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Marcos Sousa
  • 71
  • 1
  • 6

2 Answers2

0

you can try the following query :-

q=complete_name:Joseph Gar*

and then give a boost to those phrases where both Joseph and Gar match in specified order. Please note that the above will also produce those results where names are like "Garret Joseph". However, because of the boost, such results will be pushed downwards.

However, if you like only those results which match the above order, then I suggest you look at the following link :-

https://issues.apache.org/jira/browse/SOLR-1604

The above discusses wildcards in phrase.

Note:- When I used the above jar files, then sometimes, I get a max Boolean clause count exceeded (which can be increased in the solrconfig.xml. However, there is still a chance that it might not be sufficient).

Max
  • 4,067
  • 1
  • 18
  • 29
  • Strange. I can execute a "similar" query on my end. Can you please let us know if you executed the first query or did you use the jar file from the Jira ticket? Also, can you please post all the url parameters that you are passing? – Max Dec 18 '12 at 15:06
0

Try with the following field type for your field(complete_name) in schema.xml,

<fieldType name="text_search" class="solr.TextField" sortMissingLast="true" omitNorms="true">
    <analyzer>
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory" />  
    </analyzer>   
</fieldType>

and your field definition in schema.xml is like

<field name="complete_name" type="text_search" indexed="true" stored="true"/>

and search with the query like

q=complete_name:*Joseph\ Gar*

To handle special characters other than alphabets and numbers, use the escape character \ on before every character. Example: To search for text contains $, give q=*\$*

Hope this answer may resolve your problem.

Kaven
  • 312
  • 1
  • 4
  • 12