我是 elasticsearch 新手,我使用的是 5.1.2 版。我有这个索引,我不知道我是否使用 _source 字段创建得很好。我想要一个返回所有带有 loc = XXY 和 part = Z 的寄存器的查询,我该怎么做?我正在尝试这个但不起作用。任何的想法?
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 107271,
"max_score": 1,
"hits": [
{
"_index": "my_index",
"_type": "po",
"_id": "0",
"_score": 1,
"_source": {
"loc": "XXX",
"part": "YY",
"order_qty": "16",
}
},
{
"_index": "my_index",
"_type": "po",
"_id": "14",
"_score": 1,
"_source": {
"loc": "XXY",
"part": "Z",
"order_qty": "7",
}
},
{
"_index": "my_index",
"_type": "po",
"_id": "19",
"_score": 1,
"_source": {
"loc": "XXY",
"part": "Z",
"order_qty": "8",
}
...
我正在使用但不起作用的查询:
GET my_index/po/_search
{
"query" : {
"term" : { "loc" : "XXY", "part": "Z"}
}
}
映射:
{
"my_index": {
"mappings": {
"po": {
"properties": {
"loc": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"order_qty": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"part": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}