As I indicated in my original response, the fq query terms do not participate in any way in the scoring of documents - they merely filter (eliminate or keep) documents.

If you actually do want the fq terms to participate in the scoring of documents, either keep them on the original q query, or add a boosting query using the bq parameter. The latter approach works for the dismax and edismax query parsers only.

-- Jack Krupansky

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


Hi Jack,


I'm going after speed per: https://cwiki.apache.org/confluence/display/solr/Common+Query+Parameters#CommonQueryParameters-Thefq%28FilterQuery%29Parameter


If using "fq" ranking will now be different, I need to understand why. Even more, I'm now wandering, which ranking is correct the one with "fq" or without ?!!!


I'm now more puzzled about this than ever !!!!  If the following two



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



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



will not give me the same ranking, than why?


-- MJ


-----Original Message-----
From: Jack Krupansky <j...@basetechnology.com>
To: solr-user <solr-user@lucene.apache.org>
Sent: Wed, May 21, 2014 5:06 pm
Subject: Re: Using fq as OR


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