Search code examples
selectsolrsolr6

Select query for search with 2 or more words without double quotes in solr


I have a column named title. I want to search this column. There is no problem when I use single word like title:'sport' OR title:"sport". Both giving same number of record.

My problem is when I search with 2 or more words without double quotes(with double quotes giving exact result ex: title:"sport education").

title:'sport education' - returning irrelevant records(more title's don't have sport or education word)

+title:'sport education' - returns the same number of record for the search oftitle:'sport' / title:"sport".

what should I do to get atleast any one search word must match in the column?

Note: Solr version 6.3.0

Thank you in advance!


Solution

  • I bet what you are looking for is the following chain of parameters:

    http://$solr_host:8983/solr/magazines/select&q=sport+education&df=title&q.op=OR
    

    Let me decipher it for you:

    • q=sport+education. You are free to use query in such free form.
    • df=title. Here you are specifying default field for search.
    • q.op=OR (which is default, feel free to omit it). $q will be tokenized according to $df fieldType and the clauses will be joined via OR like this: title:sport OR title:education

    For more information you can follow Common Query Parameters or Local Parameters in Queries.