libreant icon indicating copy to clipboard operation
libreant copied to clipboard

searching string with slashes raise request error

Open ael-code opened this issue 9 years ago • 5 comments

to repruduce the error you can simply search / or any string containing slashes on the search page.

For example searching asdasdasdasdlsadsaas/dasd will produce the following error

RequestError: TransportError(400, u'SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[HA2s6JuLQZywwaQUuIxpJQ][libreant][0]: SearchParseException[[libreant][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"query_string": {"query": "asdasdasdasdlsadsaas/dasd", "fields": ["_text_*"]}}}]]]; nested: QueryParsingException[[libreant] Failed to parse query [asdasdasdasdlsadsaas/dasd]]; nested: ParseException[Cannot parse \'asdasdasdasdlsadsaas/dasd\': Lexical error at line 1, column 26. Encountered: <EOF> after : "/dasd"]; nested: TokenMgrError[Lexical error at line 1, column 26. Encountered: <EOF> after : "/dasd"]; }{[HA2s6JuLQZywwaQUuIxpJQ][libreant][1]: SearchParseException[[libreant][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"query_string": {"query": "asdasdasdasdlsadsaas/dasd", "fields": ["_text_*"]}}}]]]; nested: QueryParsingException[[libreant] Failed to parse query [asdasdasdasdlsadsaas/dasd]]; nested: ParseException[Cannot parse \'asdasdasdasdlsadsaas/dasd\': Lexical error at line 1, column 26. Encountered: <EOF> after : "/dasd"]; nested: TokenMgrError[Lexical error at line 1, column 26. Encountered: <EOF> after : "/dasd"]; }{[HA2s6JuLQZywwaQUuIxpJQ][libreant][2]: SearchParseException[[libreant][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"query_string": {"query": "asdasdasdasdlsadsaas/dasd", "fields": ["_text_*"]}}}]]]; nested: QueryParsingException[[libreant] Failed to parse query [asdasdasdasdlsadsaas/dasd]]; nested: ParseException[Cannot parse \'asdasdasdasdlsadsaas/dasd\': Lexical error at line 1, column 26. Encountered: <EOF> after : "/dasd"]; nested: TokenMgrError[Lexical error at line 1, column 26. Encountered: <EOF> after : "/dasd"]; }{[HA2s6JuLQZywwaQUuIxpJQ][libreant][3]: SearchParseException[[libreant][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"query_string": {"query": "asdasdasdasdlsadsaas/dasd", "fields": ["_text_*"]}}}]]]; nested: QueryParsingException[[libreant] Failed to parse query [asdasdasdasdlsadsaas/dasd]]; nested: ParseException[Cannot parse \'asdasdasdasdlsadsaas/dasd\': Lexical error at line 1, column 26. Encountered: <EOF> after : "/dasd"]; nested: TokenMgrError[Lexical error at line 1, column 26. Encountered: <EOF> after : "/dasd"]; }{[HA2s6JuLQZywwaQUuIxpJQ][libreant][4]: SearchParseException[[libreant][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"query_string": {"query": "asdasdasdasdlsadsaas/dasd", "fields": ["_text_*"]}}}]]]; nested: QueryParsingException[[libreant] Failed to parse query [asdasdasdasdlsadsaas/dasd]]; nested: ParseException[Cannot parse \'asdasdasdasdlsadsaas/dasd\': Lexical error at line 1, column 26. Encountered: <EOF> after : "/dasd"]; nested: TokenMgrError[Lexical error at line 1, column 26. Encountered: <EOF> after : "/dasd"]; }]')

ael-code avatar Mar 05 '15 21:03 ael-code

here's why: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax

in the querystring, a / is the delimiter for regular expressions. So for example, title:/ci.o/ will match both "ciao" and "cibo".

If you want to use a slash, you need to escape this with a backslash. I don't know if this behaviour is good for us, and if we can/want disable them

boyska avatar Mar 06 '15 09:03 boyska

a solution could be to enable advanced query syntax only if the query starts with a prefix

ael-code avatar Mar 08 '15 10:03 ael-code

Is this needed for 0.1.1? I don't think so; minor releases should contain small advancement and no regressions. This bug is not a regression. So we could drop it, especially if we consider that we have no consensus on how to fix it.

boyska avatar Mar 20 '15 14:03 boyska

Also searching for ":" will lead to error SearchParseException

ael-code avatar Feb 07 '16 13:02 ael-code

I think that we should follow what everyone else is doing out there: handle that kind of exceptions with a funny image (kittens welcome but not strictly required) saying that your search string is weird and failure is your responsibility. It will immediately become a feature instead of a bug. :hand: high five!

boyska avatar Feb 09 '16 00:02 boyska