How to look for utf-8 special characters in elasticsearch?

I have a problem finding a solution for requesting Unicode special characters in an Elastic search.

When I create this index:

curl -XPUT http://localhost:9200/index/type/1 -d '{"name" : "Vrba u řeky"}' 

and then I try to find the phrase "řeky", everything is fine:

 curl -XGET 'http://localhost:9200/index/type/_search?pretty=1' -d '{"query" : {"text" : { "_all" : "řeky" }}}' { "took" : 1, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 1, "max_score" : 0.10848885, "hits" : [ { "_index" : "index", "_type" : "type", "_id" : "1", "_score" : 0.10848885, "_source" : {"name" : "Vrba u řeky"} } ] } } 

But when I try to search for the same word, I find nothing:

 curl -XGET 'http://localhost:9200/index/type/_search?pretty=1' -d '{"query" : {"text" : { "_all" : "\\u0159eky" }}}' 

How can one make elasticity accept shielded strings in queries instead of raw queries?

Thanks.

+4
source share
1 answer

Assuming you use, for example, bash, you have too many backslashes:

 curl -XGET 'http://localhost:9200/index/type/_search?pretty=1' -d ' {"query" : {"text" : { "_all" : "\u0159eky" }}} ' { "took" : 16, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 1, "max_score" : 0.10848885, "hits" : [ { "_index" : "index", "_type" : "type", "_id" : "1", "_score" : 0.10848885, "_source" : {"name" : "Vrba u řeky"} } ] } } 
+5
source

Source: https://habr.com/ru/post/1389361/


All Articles