Search with multiple parameters in solr
-
21-12-2019 - |
Question
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:
OTHER TIPS
in order to perform a multicriteria request, you'd better do :
q=*:*
fq= name:*somename*
fq= specialization:*specializstr*
http req example : http://localhost:8983/solr/datav6/select?q=*%3A*&fq=data%3A*carlos*%5E5&fq=entity%3Aemployee&wt=json&indent=true
it' saffer on the results, faster on execution and consumes less ram. enjoy and give me some feedback please! :)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow