Issue 1757: Search doesn't respect OR anymore
Status:  New
Owner: ----
Reported by hughdave...@gmail.com, Jan 14, 2013
************************************************************
***** NOTE: THIS BUG TRACKER IS FOR GERRIT CODE REVIEW *****
***** DO NOT SUBMIT BUGS FOR CHROME, ANDROID, INTERNAL *****
***** ISSUES WITH YOUR COMPANY'S GERRIT SETUP, ETC.    *****
***** THOSE ISSUE BELONG IN DIFFERENT ISSUE TRACKERS!  *****
************************************************************

Affected Version:

What steps will reproduce the problem?
1. Search for string "status:open OR status:merged"
2. Compare with search of "status:open"
3. Compare with search of "status:merged"

What is the expected output? What do you see instead?
Expected output for step 1 is to see union of steps 2 and 3. What I saw was no results. Steps 2 and 3 showed correctly.

Please provide any additional information below.
http://gerrit-documentation.googlecode.com/svn/Documentation/2.5.1/user-search.html#_or

Also visible at https://gerrit-review.googlesource.com/#/q/status:open+OR+status:merged,n,z
Jul 24, 2013
#1 presich....@gmail.com
Hello guys! Has anyone found a resolution or workaround for this issue?
Jul 24, 2013
#2 dborowitz@google.com
I can reproduce this on gerrit-review.googlesource.com (2.7-rc3-964-gc6e8ab5) but it only appears to affect OR combinations of status: operators. I see the original bug is from 1/14, but much of the search operator stuff has been rewritten since then. Do you have any information about what versions are affected?
Jul 24, 2013
#3 dborowitz@google.com
Looks like a bug in our query rewrite rules (which predate the recent changes to the search system). "status:open OR status:merged" is getting rewritten to
  (r20_byOpenNext(sortkey_before:z limit:26) status:merged visibleto:ANONYMOUS)
which is obviously wrong since the manual rewrite rule is being ANDed with the other status change.

I guess the good news is the Lucene search implementation coming in 2.8 does not suffer from this bug.
Feb 13, 2014
#4 fancypan...@gmail.com
Yeah, so, did Gerrit actually move to Lucene?  Because we're seeing this precise behaviour in Gerrit 2.8.1.  A disjunctive search using in: or status: results in no results at all, which is a huge problem for us as we need this functionality to properly link Jira to gerrit.

Either that or we need a way to *not* have Gerrit by default include only open issues in the search results...
Feb 13, 2014
#5 m...@talios.com
When you install/update Gerrit there's an option to enable Lucene indexing - I've not actually tried it yet myself tho...
Feb 21, 2014
#6 icee...@googlemail.com
I can confirm this bug still is there for 2.8.1 with lucene indexing enabled. It is also visible on gerrit-review.googlesource.com.
Feb 21, 2014
#7 dborowitz@google.com
I can't reproduce this on googlesource.com:

$ curl -s 'https://gerrit-review.googlesource.com/changes/?q=status:open+OR+status:merged&n=50' | grep '"status"' | sort | uniq --count
     27     "status": "MERGED",
     23     "status": "NEW",

When I get a chance I'll add a test case for this to AbstractQueryChangesTest.
Feb 21, 2014
#8 fancypan...@gmail.com
Yeah, confirmed, it seems to be working as expected on gerrit-review.googlesource.com

Aside: We've switched to using trackingids and 'tr:' for linking to gerrit reviews from JIRA (which, unexpectedly, *doesn't* implicitly include the 'open' status as part of the search criteria), so in an unwillingness to mess with a working system, I haven't tried switching to lucene+reindexing to see if that addresses the issue in our installation.