You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Modassar Ather <mo...@gmail.com> on 2015/11/30 11:45:48 UTC

Difference in query behavior.

Hi,

I have a query title:(solr lucene api). The mm is set to 100% using q.op as
AND.
When the query is executed it returns documnets having all the terms. It
parses to following:
+(title:solr title:faceting title:api)~3

Similarlly I have another query like this topic:facet AND title:(solr
lucene api) which is parsed as:
+(+topic:facet +(title:solr title:lucene title:api)

The second query is a subset of first query but it returns more results
than the first.
Per my understanding reason being that there are two clauses in second
query 1) topic:facet which MUST occur and 2) (title:solr title:lucene
title:api) any of the terms MUST occur.
In first query there are 3 clauses which has SHOULD occur in between terms
but due to 100% mm all terms are matched.

Kindly help me understand how I can get the subset of result of query 1 by
query 2.
I understand if I put +/AND in between the clauses it will work but the
same is not required in query one.
Is there a way I can group the clauses which ensures that the first clause
and the terms of other clause all should match as in the query first all
the clauses are matched.
Also let me know how ~ is different from phrase slop in the case of first
query.

Thanks,
Modassar

Re: Difference in query behavior.

Posted by Jack Krupansky <ja...@gmail.com>.
The mm parameter or default operator logic only applies to the top level of
the query. Once you get nested in parentheses below the top level,
Solr/Lucene reverts to the default of the OR (SHOULD) operator.

-- Jack Krupansky

On Mon, Nov 30, 2015 at 5:45 AM, Modassar Ather <mo...@gmail.com>
wrote:

> Hi,
>
> I have a query title:(solr lucene api). The mm is set to 100% using q.op as
> AND.
> When the query is executed it returns documnets having all the terms. It
> parses to following:
> +(title:solr title:faceting title:api)~3
>
> Similarlly I have another query like this topic:facet AND title:(solr
> lucene api) which is parsed as:
> +(+topic:facet +(title:solr title:lucene title:api)
>
> The second query is a subset of first query but it returns more results
> than the first.
> Per my understanding reason being that there are two clauses in second
> query 1) topic:facet which MUST occur and 2) (title:solr title:lucene
> title:api) any of the terms MUST occur.
> In first query there are 3 clauses which has SHOULD occur in between terms
> but due to 100% mm all terms are matched.
>
> Kindly help me understand how I can get the subset of result of query 1 by
> query 2.
> I understand if I put +/AND in between the clauses it will work but the
> same is not required in query one.
> Is there a way I can group the clauses which ensures that the first clause
> and the terms of other clause all should match as in the query first all
> the clauses are matched.
> Also let me know how ~ is different from phrase slop in the case of first
> query.
>
> Thanks,
> Modassar
>

Re: Difference in query behavior.

Posted by Upayavira <uv...@odoko.co.uk>.
I cannot immediately explain the behaviour you are seeing, but can't you
use a filter query to achieve the same?

Add fq=topic:facet to your query string, and you'll be set.

As to the original behaviour, the parsed query looks wrong, as it is
missing a bracket. Can you provide all of the versions of the queries
that Solr gives to you, along with the JSON/XML that wraps them?

Upayavira

On Mon, Nov 30, 2015, at 10:45 AM, Modassar Ather wrote:
> Hi,
> 
> I have a query title:(solr lucene api). The mm is set to 100% using q.op
> as
> AND.
> When the query is executed it returns documnets having all the terms. It
> parses to following:
> +(title:solr title:faceting title:api)~3
> 
> Similarlly I have another query like this topic:facet AND title:(solr
> lucene api) which is parsed as:
> +(+topic:facet +(title:solr title:lucene title:api)
> 
> The second query is a subset of first query but it returns more results
> than the first.
> Per my understanding reason being that there are two clauses in second
> query 1) topic:facet which MUST occur and 2) (title:solr title:lucene
> title:api) any of the terms MUST occur.
> In first query there are 3 clauses which has SHOULD occur in between
> terms
> but due to 100% mm all terms are matched.
> 
> Kindly help me understand how I can get the subset of result of query 1
> by
> query 2.
> I understand if I put +/AND in between the clauses it will work but the
> same is not required in query one.
> Is there a way I can group the clauses which ensures that the first
> clause
> and the terms of other clause all should match as in the query first all
> the clauses are matched.
> Also let me know how ~ is different from phrase slop in the case of first
> query.
> 
> Thanks,
> Modassar

Re: Difference in query behavior.

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
On 30 November 2015 at 05:45, Modassar Ather <mo...@gmail.com> wrote:
>
> I have a query title:(solr lucene api). The mm is set to 100% using q.op as
> +(title:solr **title:faceting** title:api)~3

Does it though? solr lucene api => solr faceting api!

Is it possible you are staring at the wrong tab and the counts don't
match. I've done that often enough :-(

Regards,
   Alex.

----
Newsletter and resources for Solr beginners and intermediates:
http://www.solr-start.com/

Re: Difference in query behavior.

Posted by Modassar Ather <mo...@gmail.com>.
Thanks for your response.

Upayavira : The missing bracket is a copy paste error. Correct parsed query
: +(+topic:facet +(title:solr title:lucene title:api)). Use of fq is not an
option as these are user queries.
Alexandre : That is just an example query. Those terms used are just to
explain the behavior. Basically the query forms can be seen as field:(term1
term2 term3) and field1:term4 AND field:(term1 term2 term3)
                  The second query should bring the subset of the first
query but that is not happening.

Thanks Jack for your input.

Please let me know if there is a way to achieve the subset of first query
from second query. As per my understanding of the code I saw that until
there is an OR in between clauses the mm is not considered. So for the
query field1:term4 AND field:(term1 term2 term3) mm is not considered at
all.

Regards,
Modassar

On Tue, Dec 1, 2015 at 10:14 AM, Modassar Ather <mo...@gmail.com>
wrote:

> Thanks for your response.
>
> Upayavira : The missing bracket is a copy paste error. Correct parsed
> query : +(+topic:facet +(title:solr title:lucene title:api)). Use of fq is
> not an option as these are user queries.
> Alexandre : That is just an example query. Those terms used are just to
> explain the behavior. Basically the query forms can be seen as field:(term1
> term2 term3) and field1:term4 AND field:(term1 term2 term3)
>                   The second query should bring the subset of the first
> query but that is not happening.
>
> Thanks Jack for your input.
>
> Please let me know if there is a way to achieve the subset of first query
> from second query.
>
> Regards,
> Modassar
>
>
> On Tue, Dec 1, 2015 at 9:57 AM, Modassar Ather <mo...@gmail.com>
> wrote:
>
>> Hi Tim,
>>
>> I am using the SpanQueryParser for phrases particularly.
>>
>> Thanks,
>> Modassar
>>
>> On Mon, Nov 30, 2015 at 6:27 PM, Allison, Timothy B. <ta...@mitre.org>
>> wrote:
>>
>>> Out of curiosity, how does the SpanQueryParser work on this?  Or have
>>> you stopped using that?
>>>
>>> Cheers,
>>>
>>>               Tim
>>>
>>> -----Original Message-----
>>> From: Modassar Ather [mailto:modather1981@gmail.com]
>>> Sent: Monday, November 30, 2015 5:46 AM
>>> To: solr-user@lucene.apache.org
>>> Subject: Difference in query behavior.
>>>
>>> Hi,
>>>
>>> I have a query title:(solr lucene api). The mm is set to 100% using q.op
>>> as AND.
>>> When the query is executed it returns documnets having all the terms. It
>>> parses to following:
>>> +(title:solr title:faceting title:api)~3
>>>
>>> Similarlly I have another query like this topic:facet AND title:(solr
>>> lucene api) which is parsed as:
>>> +(+topic:facet +(title:solr title:lucene title:api)
>>>
>>> The second query is a subset of first query but it returns more results
>>> than the first.
>>> Per my understanding reason being that there are two clauses in second
>>> query 1) topic:facet which MUST occur and 2) (title:solr title:lucene
>>> title:api) any of the terms MUST occur.
>>> In first query there are 3 clauses which has SHOULD occur in between
>>> terms but due to 100% mm all terms are matched.
>>>
>>> Kindly help me understand how I can get the subset of result of query 1
>>> by query 2.
>>> I understand if I put +/AND in between the clauses it will work but the
>>> same is not required in query one.
>>> Is there a way I can group the clauses which ensures that the first
>>> clause and the terms of other clause all should match as in the query first
>>> all the clauses are matched.
>>> Also let me know how ~ is different from phrase slop in the case of
>>> first query.
>>>
>>> Thanks,
>>> Modassar
>>>
>>
>>
>