Hello.
I have a field which contains forward slashes (it's a usual path). I'm trying to execute this Query:
QueryBuildres.termQuery("pageId", QueryParser.escape("/my/field/val"))
and I cannot get any results. When I'm looking for 'val' only, then I get the proper results. Any ideas why is that happening? Of course without escaping it also doesn't return the results.
QueryParser.escape parses string properly( it contains "/" for every slash), but when request goes to elasticsearch it's double escaped ("\/)
Here is the log:
[2015-07-10 01:53:00,063][WARN ][index.search.slowlog.query] [Aaa AA] [index_name][4] took[420.8micros], took_millis[0], types[page], stats[], search_type[QUERY_THEN_FETCH], total_shards[5], source[{"query":{"term":{"pageId":"\\/path\\/and\\/testestest"}}}], extra_source[],
Also I have noticed that It works when I'm using querystring:
QueryBuilders.queryString("pageId:" + QueryParser.escape("/my/field/val"))
, but I wouldn't like to use it like that and type everything by hand.
I also have checked if it works from the console (using cURL):
curl -XGET 'http://localhost:9200/index/_search?q=pageId:\-path\/test'