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.
*** Bug 788623 has been marked as a duplicate of this bug. ***
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.
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.
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
Verified in brew build 0.1.303-1.el6
getting rid of 6.0.0 version since that doesn't exist