If you only want to eliminate `d` from your search, this can be easily done by adding a `must_not` leaf to your `compound-query`.
{
"query": {
"constant_score": {
"filter": {
"bool": {
"must": {
"match": {
"content": {
"query": "a b c",
"operator": "and"
}
}
},
"must_not": {
"match": {
"content": "d"
}
}
}
}
}
}
}
`constant-score` improves performance by caching the results
Results
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 1.0,
"hits": [
{
...
"_score": 1.0,
"_source": {
"content": "a b c"
}
},
{ ...
"_score": 1.0,
"_source": {
"content": "a b c f"
}
}
]
}
Try to use **keyword** instead of **text** in your mapping like:
{
"mappings": {
"your_type_name": {
"properties": {
"metadata" : {
"type" : "nested",
"properties" : {
"name" : {
"type" : "keyword"
},
"value" : {
"type" :"keyword"
}
}
}
}
}
}
}
These fields won't be analyzed. Then you should reindex your data and to query your data you should replace match (which is analyzed query) with **term**.
{
"query": {
"bool": {
"must": [
{
"nested": {
"path": "metadata",
"query": {
"bool": {
"must": [
{
"term": {
"metadata.name": "number"
}
},
{
"term": {
"metadata.value": "2014.NWJSD.47"
}
}
]
}
}
}
}
]
}
}
}