Bug 30173 - The suppress limit breaks the OPAC adv search using OR
Summary: The suppress limit breaks the OPAC adv search using OR
Status: RESOLVED DUPLICATE of bug 30152
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching - Elasticsearch (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Blou
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-23 21:38 UTC by Blou
Modified: 2022-05-11 19:57 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 30173: The suppress limit breaks the OPAC adv search using OR (2.78 KB, patch)
2022-02-23 21:39 UTC, Blou
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Blou 2022-02-23 21:38:55 UTC
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.
Comment 1 Blou 2022-02-23 21:39:40 UTC
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.
Comment 2 Blou 2022-02-23 21:40:56 UTC
This occurs in 20.05+ with Elastic Search.
Comment 3 Kevin Carnes 2022-02-24 07:56:28 UTC

*** This bug has been marked as a duplicate of bug 30152 ***