Я делаю поиск текста через ElasticSearch, и есть проблема с запросом с типом термина. То, что я делаю ниже, в основном,Поддерживает ли ElasticSearch Unicode/Chinese?
- Добавить документ с китайской струной (你好).
- Выполнение запроса текстовым методом и возврат документа.
- Запрос с помощью метода терминов, ничего не возвращайте.
Итак, почему это происходит? и как его решить.
➜ curl -XPOST 'http://localhost:9200/test/test/' -d '{ "name" : "你好" }'
{
"ok": true,
"_index": "test",
"_type": "test",
"_id": "VdV8K26-QyiSCvDrUN00Nw",
"_version": 1
}
➜ curl -XGET 'http://localhost:9200/test/test/_mapping?pretty=1'
{
"test" : {
"properties" : {
"name" : {
"type" : "string"
}
}
}
}
➜ curl -XGET 'http://localhost:9200/test/test/_search?pretty=1'
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1.0,
"hits": [
{
"_index": "test",
"_type": "test",
"_id": "VdV8K26-QyiSCvDrUN00Nw",
"_score": 1.0,
"_source": {
"name": "你好"
}
}
]
}
}
➜ curl -XGET 'http://localhost:9200/test/test/_search?pretty=1' -d '{
"query": {
"text": {
"name": "你好"
}
}
}'
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.8838835,
"hits": [
{
"_index": "test",
"_type": "test",
"_id": "VdV8K26-QyiSCvDrUN00Nw",
"_score": 0.8838835,
"_source": {
"name": "你好"
}
}
]
}
}
➜ curl -XGET 'http://localhost:9200/test/test/_search?pretty=1' -d '{
"query": {
"term": {
"name": "你好"
}
}
}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}