Search code examples
solrsolr-query-syntax

Search with multiple parameters in solr


Currently I having the query like this

q=mysearchparameters

It is working fine, and I think it will search for this keyword in all the fields, now I want to retrieve data only based in some specific field like this

q=name:'somename'+specialization:'somespecialization' 

is it possible to query like, here I getting some unexpected datas for my second query.


Solution

  • You can have multiple queries, ANDed together, like this:

    q=name:somename AND specialization:somespecialization
    

    or ORer together like this:

    q=name:somename OR specialization:somespecialization
    

    Or you can use filter queries to AND them together:

    q=*:*&fq=name:somename&fq=specialization:somespecialization
    

    I won't get into queries versus filter queries as it is covered better elsewhere:

    SOLR filter-query vs main-query