I have an index (name: "index1") pointing to multiple documents in ElasticSearch.
The format(json) of a document is -
{
"_index": "index1",
"_type": "someType",
"_id": "randomIDBlahBlah",
"_source": {
"version": "2018",
"fields": [
{
"field": "A.B",
"lineNumber": 1
},
{
"field": "C.D",
"lineNumber": 2
},
{
"field": "A.E",
"lineNumber": 3
}]
},
"fields": {
"created": [
"2017-01-19T20:11:07.977Z"
]
},
"sort": [
2324343
]
}
Here is the mapping -
{
"index1": {
"mappings": {
"mapping": {
"properties": {
"branch": {
"type": "text"
},
"created": {
"type": "date"
},
"fields": {
"type": "nested",
"properties": {
"field": {
"type": "text"
},
"lineNumber": {
"type": "integer"
}
}
}
}
}
}
}
}
Similarly, there are multiple documents under that index, same format, but different field data.
Now, I am trying to perform the below mentioned Elastic Search on a specific field (here - A.B), it is giving me all the results from all the documents as if it's a search for all the fields.
I want to see only that specific field result, not all the results.
This is my ES query -
POST index1/_search
{
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"nested": {
"path": "fields",
"query": {
"match_phrase": {
"fields.field": "A.B"
}
}
}
}
]
}
}
]
}
}
}
Where am I doing wrong in the ES query?
fields.field? Or I would be more understandable if you can add the mapping ofindex1to your question. - Nishant