When I search in Solr 4.0 with the following two filter queries separately, it works as expected.
{!complexphrase inOrder=true}employeeName_t:"Mike R*"empDate_dt:[2016-10-10T00:00:00Z TO 2016-10-10T23:59:59Z]But I am not getting proper search results when I combine these two queries(Irrespective of the order).
{!complexphrase inOrder=true}employeeName_t:"Mike R*" AND empDate_dt:[2016-10-10T00:00:00Z TO 2016-10-10T23:59:59Z]
This query gives me zero search results in Solr
"response": { "numFound":0, "start":0, "maxScore":0, "docs":[] }
empDate_dt:[2016-10-10T00:00:00Z TO 2016-10-10T23:59:59Z] AND {!complexphrase inOrder=true}employeeName_t:"Mike R*"
Whereas change in query order gives me parse exception as follows
"error":{ "msg": "org.apache.solr.search.SyntaxError: org.apache.lucene.queryparser.classic.ParseException: Cannot parse 'employeeName_t:\"Mike': Lexical error at line 1, column 21. Encountered: after : \"\\"Mike\"",code:400 }
Using ComplexPhraseQueryParser for partial search in solr.Need to use both queries.Any suggestions to this would be greatly appreciated.
Add a comment
|
1 Answer
I suggest you to use fq parameter.
docs are retrieved with query as :"Mike R*" and filtered with dates specified in fq parameter.
Example:
q={!complexphrase inOrder=true}employeeName_t:"Mike R*"&fq=empDate_dt:["2016-10-10T00:00:00Z" TO "2016-10-10T23:59:59Z"]
4 Comments
Vish
Both are used as filter queries[Multiple filters].Is it possible to use them both in fq and make it work? Thanks in advance.
Vinod
yes, SOLR (>4.5) supports, fq=(field1:value1 OR field2:value2). you can use
q=mainQuery(*:*)&fq=({!complexphrase inOrder=true}employeeName_t:"Mike R*" AND empDate_dt:["2016-10-10T00:00:00Z" TO "2016-10-10T23:59:59Z"] )Vinod
change main query q and operator accordingly.
Vish
There seems to be some problem with date alone.Your query works fine with string,text fields and even integer fields,if given in the second part after complex query.Just not with date.