Bug 789533 - Templates: Entering a "-" in the Packages search throws massive error.
Summary: Templates: Entering a "-" in the Packages search throws massive error.
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: WebUI
Version: 6.0.1
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: Brad Buckingham
QA Contact: Katello QA List
URL:
Whiteboard:
: 788623 (view as bug list)
Depends On:
Blocks: katello-blockers 788622 796852
TreeView+ depends on / blocked
 
Reported: 2012-02-11 02:43 UTC by Corey Welton
Modified: 2019-09-26 13:30 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-08-22 18:26:27 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 788622 0 high CLOSED Search does not handle dash correctly 2021-02-22 00:41:40 UTC

Internal Links: 788622

Description Corey Welton 2012-02-11 02:43:11 UTC
Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. Sync Content
2. Create new template
3. $template > Packages
4. In the Search field, type the character "-"
  
Actual results:
500 : {"error":"SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[qrZS16CqQ7-UQ4fXe3rRlA][katello_package][2]: SearchParseException[[katello_package][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"fields\":[\"name\"],\"query\":{\"query_string\":{\"query\":\"name:-\"}}}]]]; nested: QueryParsingException[[katello_package] Failed to parse query [name:-]]; nested: ParseException[Cannot parse 'name:-': Encountered \" \"-\" \"- \"\" at line 1, column 5.\nWas expecting one of:\n \"(\" ...\n \"*\" ...\n ...\n ...\n ...\n ...\n \"[\" ...\n \"{\" ...\n ...\n ]; nested: ParseException[Encountered \" \"-\" \"- \"\" at line 1, column 5.\nWas expecting one of:\n \"(\" ...\n \"*\" ...\n ...\n ...\n ...\n ...\n \"[\" ...\n \"{\" ...\n ...\n ]; }{[qrZS16CqQ7-UQ4fXe3rRlA][katello_package][1]: SearchParseException[[katello_package][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"fields\":[\"name\"],\"query\":{\"query_string\":{\"query\":\"name:-\"}}}]]]; nested: QueryParsingException[[katello_package] Failed to parse query [name:-]]; nested: ParseException[Cannot parse 'name:-': Encountered \" \"-\" \"- \"\" at line 1, column 5.\nWas expecting one of:\n \"(\" ...\n \"*\" ...\n ...\n ...\n ...\n ...\n \"[\" ...\n \"{\" ...\n ...\n ]; nested: ParseException[Encountered \" \"-\" \"- \"\" at line 1, column 5.\nWas expecting one of:\n \"(\" ...\n \"*\" ...\n ...\n ...\n ...\n ...\n \"[\" ...\n \"{\" ...\n ...\n ]; }{[qrZS16CqQ7-UQ4fXe3rRlA][katello_package][3]: SearchParseException[[katello_package][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"fields\":[\"name\"],\"query\":{\"query_string\":{\"query\":\"name:-\"}}}]]]; nested: QueryParsingException[[katello_package] Failed to parse query [name:-]]; nested: ParseException[Cannot parse 'name:-': Encountered \" \"-\" \"- \"\" at line 1, column 5.\nWas expecting one of:\n \"(\" ...\n \"*\" ...\n ...\n ...\n ...\n ...\n \"[\" ...\n \"{\" ...\n ...\n ]; nested: ParseException[Encountered \" \"-\" \"- \"\" at line 1, column 5.\nWas expecting one of:\n \"(\" ...\n \"*\" ...\n ...\n ...\n ...\n ...\n \"[\" ...\n \"{\" ...\n ...\n ]; }{[qrZS16CqQ7-UQ4fXe3rRlA][katello_package][0]: SearchParseException[[katello_package][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"fields\":[\"name\"],\"query\":{\"query_string\":{\"query\":\"name:-\"}}}]]]; 

Expected results:
No spammy error.

Additional info:

I wasn't immediately able to reproduce this outside "Packages"

Given that I can't imagine a lot of people are going to search for something prepended with a dash, it's not likely that this is going to be seen a lot. but when it is, it takes up the whole screen.

Comment 1 Mike McCune 2012-02-13 23:46:13 UTC
*** Bug 788623 has been marked as a duplicate of this bug. ***

Comment 2 Brad Buckingham 2012-02-15 17:11:37 UTC
While investigating this BZ, had some discussion on #elasticsearch.  Based on feedback from the Tire gem owner, he recommends that we use 'text' queries, since the interface the user will be using is a text input.  That said, the current tire gem does not support this type of query; however, changes were pushed yesterday to his github to support what we need.  The github reference is: 

https://github.com/karmi/tire/pull/168

The master link is: 

https://github.com/karmi/tire


I have done some curl queries to elasticsearch using text queries and it appears that this type of query would avoid the above error.

Comment 4 Brad Buckingham 2012-02-27 22:14:59 UTC
Shannon created a gem for us to test with based on the github in comment #2. 
The results of the test look promising.  Search queries using a leading '-' as
well as those containing a '-' within the query appear to behave properly.

Will see if we can get this gem pulled in to our base and make the appropriate
changes to Katello to use it.  One thing to note, this new version of the gem
also has a dependency on another gem (hashr), which we do not currently use;
however, doesn't appear to have any adverse affects.

Comment 5 Brad Buckingham 2012-03-05 20:29:57 UTC
After further investigation of 'text' queries, decided to continue to use Lucene query syntax for the queries from Katello.  It seems that using 'text' queries would help to solve the issue observed with '-' in queries; however, it would also introduce additional complexities or reduce the search capabilities available to users.  

In Lucene query syntax, the '-' is an operator that may be used to exclude results/documents that contain the term following the '-'.  As a result, the behavior observed by users was essentially that operator being applied.

Moving to using a 'text' query (not based on Lucene syntax), would resolve this issue; however, it also eliminates features of Lucene that are useful for Katello users (such as AND and OR operators).  We could implement those ourselves; however, it would require defining our own search query syntax and parser, which may not be desirable in the long-term.

As a result, updated Katello to 'disable' the behavior of the '-' operator.  Essentially, this means 'escaping' anytime a user enters a '-'.  

commit: 6b9ea70884ba125ee422ec724bfb4d3271f43f29

Comment 7 Corey Welton 2012-03-07 21:38:39 UTC
Verified in brew build 0.1.303-1.el6

Comment 9 Mike McCune 2013-08-16 17:52:04 UTC
getting rid of 6.0.0 version since that doesn't exist


Note You need to log in before you can comment on or make changes to this bug.