ETT-827: full-text advanced search boolean operator bug fix #136
+133
−18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This work-around more or less fixes the bug that was described in the ticket, but there is more under the surface here that I don't 100% understand.
To set the scene: Looking at this form, it's visually obvious that there can be 4 keywords/fields/types and only 3 boolean operators at the maximum. @moseshll discovered that
op1/[bools][0]seems to be doing nothing, and I agree, so it gets skipped in this new URL construction. All other search-related arrays are filtered against thelookFors/keyword array so that the related indexes are filtered and reassigned. In a search on prod, searching for "apples" on line 1 and "oranges" on line 4 results in a URL likeq1=apples&q4=oranges&op1=AND&op4=AND. This fix changes changes the URL output to something likeq1=apples&q2=oranges&op2=AND.Some history: The version of advanced search before this searched groups of clauses, and I think there is some leftover logic for that hanging out here in a way that isn’t supported in the interface. Lianet’s full-text XML spreadsheet indicates that the param “OP3” is “the operator between second and third search fields, i.e. between groups.” In the old interface, there were two groups of inputs connected with a separate boolean, making it possible to search like

(cake AND pie) OR (cake AND ice cream). Theop3param seems to be that connecting OR operator in my example. I'm not sure this makes much of a difference in search results now that I'm re-writing the placement of keywords (e.g.q1=cake&q4=pie&op1=AND&op4=ANDis nowq1=cake&q2=pie&op2=AND), but in prod currently, if you try to do a search on lines 2 and 3 or 3 and 4 without anything in the first line, it spits out an error about parentheses and/or booleans.This fix unfortunately creates a new sporadic bug in catalog advanced search. Occasionally, the third boolean radio group will have nothing selected, just two empty radio buttons. This doesn't really affect the searching mechanism or outcome of the search since a user can just select one and move on, but it is annoying. Thankfully (?), it's pretty challenging to get to the catalog version of advanced search, so I'm inclined to ignore this problem until we get complaints about it and/or redesign search.