The whole point of a filter query is to hide data but without impacting the scoring for the non-hidden data. A second goal is performance since the filter query can be cached.

So, the immediate question for you is whether you really want a true filter query, or if you actually do what the filtering terms to participate in the document scoring.

In other words, what exactly were you trying to achieve by using fq?

-- Jack Krupansky

-----Original Message----- From: johnmu...@aol.com
Sent: Wednesday, May 21, 2014 12:19 PM
To: solr-user@lucene.apache.org
Subject: Re: Using fq as OR


Answering Jack's question first: the result is different, by few counts, but I found my problem:I was using the wrong syntax in my code vs. what I posted here:


I was using


   q=(search string ...) AND (type:type_a OR type_b OR type_c OR ...)


(see how I left out "type:" from "type_b" and "type_c", etc.?!


Shawn and all, now the hit count is the same but ranking is totally different, how come ?!!! I'm not using edismax, I'm using the default query parser, I'm also using the default sort. You said the "order" will likely be different, which it is, why? If I cannot explain it to my users, they will be confused because they can type in directly the search syntax (when "fq" is not used) and expect to see the same result for when I grammatically in my code apply "fq".


Same data, but different path, giving me different rank result, is not good.


-- MJ



-----Original Message-----
From: Shawn Heisey <s...@elyograg.org>
To: solr-user <solr-user@lucene.apache.org>
Sent: Wed, May 21, 2014 11:42 am
Subject: Re: Using fq as OR


On 5/21/2014 9:26 AM, johnmu...@aol.com wrote:
Currently, I'm building my search as follows:


q=(search string ...) AND (type:type_a OR type:type_b OR type:type_c OR
...)


Which means anything I search for will be AND'ed to be in either fields that
have "type_a", "type_b", "type_c", etc. (I have defaultOperator set to "AND")


Now, I need to use "fq" so I'm not sure how to build my search string to get
the same result!!


I have tried the following:


    q=search string ...&fq=type:type_a&fq=type:type_b&fq=type:type_c&...


But this isn't the same because each additional "fq" is now being treated as
AND (keep in mind, I have defaultOperator set to "AND" and I cannot change
that).


I have tried the following:


    q=search string ...&fq=type:(type_a OR type_b OR type_c OR ...)


But the result I get back is not the same.

If you are using the standard (lucene) query parser for your queries,
then fq should behave exactly the same.  If you are using a different
query parser (edismax, for example) then fq may not behave the same,
because it will use the lucene query parser.

With the standard query parser, if your original query looks like the
following:

q=(query) AND (filter)

The query below should produce exactly the same results -- although if
you are using the default relevance sort, the *order* is likely to be
different, because filter queries do not affect the document scores, but
everything in the q parameter does.

q=(query)&fq=(filter)

Thanks,
Shawn



Reply via email to