0

We have a use case that require us to fetch all records that has an exact match on any field value. E.g. check if any of the below field has a exact string value as "auto-scaling-groups"

Record 1: { "name": "auto-scaling-groups", "created_by": "John" }
Record 2: { "name": "postgres-db-node", "managed_by": "auto-scaling-groups" }
Record 3: { "name": "postgres-db-cluster", "managed_by": "auto-scaling-groups-manager"}
Record 4: { "name": "postgres-db-monitoring", "managed_by": "auto-scaling-scheduler"}

The query result should only return records 1 and 2 but not 3 and 4.

Please note that we have ES cluster v1.7 and do not have luxury of using latest features such as keyword analyzer as below.

{
    "query": {
        "query_string": {
            "query": "auto-scaling-groups",
            "analyzer": "keyword"
        }
    }
}
Azura
  • 21
  • 1
  • 3

1 Answers1

0

If you don't have a keyword field for your text fields on which you need to search, ie name, created_by and managed_by than It would be difficult to achieve your use-case, what you can do is create a keyword data type for all these fields and than you can use the term query on search on the keyword fields to get the exact match.

Amit
  • 30,756
  • 6
  • 57
  • 88