When using the advanced search, it is possible to specify an OR (instead of the default AND) between the terms. In the OPAC, the system preferences OpacSuppression will add a limit to every search as "suppress:false". The problem is that the limit is simply added as "AND suppress:false" to the query, without validating if it makes sense. In the case of OR searches, it does not: (title:PuttingHarry) OR (title:HarryPutter) AND suppress:false will not produce the desired results.
Created attachment 131050 [details] [review] Bug 30173: The suppress limit breaks the OPAC adv search using OR When using the advanced search, it is possible to specify an OR (instead of the default AND) between the terms. In the OPAC, the system preferences OpacSuppression will add a limit to every search as "suppress:false". The problem is that the limit is simply added as "AND suppress:false" to the query, without validating if it makes sense. In the case of OR searches, it does not: (title:PuttingHarry) OR (title:HarryPutter) AND suppress:false will not produce the desired results. This fix (suggested by Kevin Carnes) makes sure to envelop the search terms before padding the AND suppress:false. To test: 1) Create two records with very distinctive titles, and prove that search one by title only return that one result. Same for the other. 2) Modify the OpacSuppression syspref to select "Hide" 3) Turn ON the ES tracing by editing koha-conf.xml and adding <trace_to>Stderr</trace_to> under elasticsearch. That will allow you to see the strings generated. 4) Go to the advsearch in OPAC, do an OR search for both titles. In your logs, you should see something like "query" : "(title:TITLE1) OR (title:TITLE2) AND suppress:false" and get only one result. 5) Apply the patch, run again, this time the log should show "query" : "((title:TITLE1) OR (title:TITLE2)) AND suppress:false" and return two results.
This occurs in 20.05+ with Elastic Search.
*** This bug has been marked as a duplicate of bug 30152 ***