我尝试使用Jest创建映射和索引。 我插入一些数据后,我试图过滤查询,它不起作用。
我有一个像这样的对象映射:
http://localhost:9200/contacts?pretty=true
"contacts" : {
...
"mappings" : {
"contact" : {
"properties" : {
...
"user" : {
"properties" : {
"id" : {
"type" : "long"
},
"uuid" : {
"type" : "string"
}
}
}
}
}
数据:
{
"_index" : "contacts",
"_type" : "contact",
"_id" : "131530ff-d125-47c1-8fae-f48f2def9037",
"_version" : 1,
"found" : true,
"_source":{"id":"131530ff-d125-47c1-8fae-f48f2def9037","shared":false,"favourite":false,"user":{"id":1,"uuid":"AB353469"}}
}
我的查询:
http://localhost:9200/contacts/_search
{
"query":{
"filtered":{
...
"filter":{
"term" : {
"user.uuid" : "AB353469" }
}
}
}
}
响应:
{
"took": 14,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
你能告诉我为什么它不起作用吗? 非常感谢你!
P.S: - Elasticsearch版本:1.7.2
答案 0 :(得分:2)
从
更改initiatorUuid映射 "initiatorUuid" : {
"type" : "string"
}
到
"initiatorUuid" : {
"type" : "string",
"index": "not_analyzed"
}
重新创建索引,重新索引文档并重试。