I'm new with elasticsearch, I'am using version 5.1.2. I have this index, I don't know If I created well with the _source field. I want a query that returns all registers with loc = XXY and part = Z, how can I do it? I am trying with this but not works. Any idea?
{
"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",
}
...
The query that I am using but not works:
GET my_index/po/_search
{
"query" : {
"term" : { "loc" : "XXY", "part": "Z"}
}
}
Mappings:
{
"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
}
}
}
}
}
}
}
}