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 dshih <ds...@tableau.com> on 2018/09/08 00:59:39 UTC

local "q.op=AND" ignored for edismax query

SOLR 7.4.0

Apologies if this has been answered, but I can't find the answer for the
life of me if it has been.

Query:
/select?q={!q.op=AND}mysearchtext*&defType=edismax&debugQuery=true

Result:
"querystring": "{!q.op=AND}mysearchtext*",
"parsedquery": "+DisjunctionMaxQuery(((Synonym(text:q
text:qopandmysearchtext text:{!q.op=and}mysearchtext*) text:op text:and
text:mysearchtext)))"

In the above, I'm just trying to set the query operator to AND while leaving
the default as OR.  It looks like q.op is being completely ignored (and ends
up as part of the search terms).

I did read https://lucene.apache.org/solr/guide/7_2/solr-upgrade-notes.html
regarding switching the query parser using local parameters, but that is not
what is happening here.  Incidentally, if I set luceneMatchVersion=7.1.0, I
can workaround this issue by doing "{!edismax q.op=and}", but that doesn't
work with 7.4.0.

I also read a number of threads/bugs about changes to the "mm" option, but I
don't think that's relevant here either.

The above works in 4.10.3 (long time ago - I know).  What is the recommended
way to get the same functionality?



--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html

Re: local "q.op=AND" ignored for edismax query

Posted by dshih <ds...@tableau.com>.
Thanks, Shawn.

We made a change to add q.op=AND as a separate param and found a few issues. 
For example, we have a query that filters out guest users in our product. 
It boils down to:

select?q=myname*&q.op=AND&fq=(-(site_role:"Guest"))

debugQuery shows this is parsed as the following, which does not work:
+(-(+site_role:Guest))

Previously, because we were setting q.op=AND as a local param, i.e.
"q={!q.op=AND}myname*", my understanding is the effective operator for the
fq param was OR.  So the fq param parsed as:
-site_role:Guest

I feel like we can fix the issue by just removing the outer parenthesis. 
But I haven't been able to figure out why the operator change (OR to AND)
has this effect.

Any insight appreciated!



--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html

Re: local "q.op=AND" ignored for edismax query

Posted by Shawn Heisey <el...@elyograg.org>.
On 9/10/2018 5:45 PM, dshih wrote:
> Based on what you said, is my query supposed to work as is if I set
> luceneMatchVersion=7.1.0?  It does not appear to.

It does look like a luceneMatchVersion check was added to the change in 
SOLR-11501, so I would expect that to work.  Setting luceneMatchVersion 
will only affect the parts of Lucene and Solr code that have been 
specifically altered to pay attention to it.

> Also, my understanding is using the local param makes the AND apply only to
> the following search terms provided to the "q" query string.  If I add a
> q.op=AND as a separate URL parameter, wouldn't that operator also apply for
> everything else in the query operation?

Yes.  But since in most cases localparams have to be at the very 
beginning of the search string anyway, and cannot be in the middle like 
you have them, this is not much of a limitation.

Thanks,
Shawn


Re: local "q.op=AND" ignored for edismax query

Posted by dshih <ds...@tableau.com>.
Thanks Shawn!

Based on what you said, is my query supposed to work as is if I set
luceneMatchVersion=7.1.0?  It does not appear to.

Also, my understanding is using the local param makes the AND apply only to
the following search terms provided to the "q" query string.  If I add a
q.op=AND as a separate URL parameter, wouldn't that operator also apply for
everything else in the query operation?



--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html

Re: local "q.op=AND" ignored for edismax query

Posted by Shawn Heisey <ap...@elyograg.org>.
On 9/7/2018 6:59 PM, dshih wrote:
> Query:
> /select?q={!q.op=AND}mysearchtext*&defType=edismax&debugQuery=true
>
> Result:
> "querystring": "{!q.op=AND}mysearchtext*",
> "parsedquery": "+DisjunctionMaxQuery(((Synonym(text:q
> text:qopandmysearchtext text:{!q.op=and}mysearchtext*) text:op text:and
> text:mysearchtext)))"
>
> In the above, I'm just trying to set the query operator to AND while leaving
> the default as OR.  It looks like q.op is being completely ignored (and ends
> up as part of the search terms).

Since 7.2, you can only use certain localparams if defType is lucene or 
func.  The lucene parser is the default.  Since you have changed defType 
to edismax, localparams will not work.   Just add q.op as a separate 
parameter.

/select?q=mysearchtext*&defType=edismax&debugQuery=true&q.op=AND

Or use mm=100% instead.  Which is effectively what q.op=AND does.

This is the issue that made the change in 7.2:

https://issues.apache.org/jira/browse/SOLR-11501

Thanks,
Shawn