Exact word search

Hi.
I need help with exact search. In some cases I need to search phrase includes word, in some cases I need to find documents where field value matches exactly search query.

For example, I have this documents:

{"match_all": {}}

"hits": [{"_id": "0", "_index": "test_index", "_score": 1.0, "_source": {"fields": {"target": "VALUE"}, "some_key": "value"}, "_type": "_doc"},
         {"_id": "1", "_index": "test_index", "_score": 1.0, "_source": {"fields": {"target": "TEST VALUE"}, "some_key": "value"}, "_type": "_doc"},
         {"_id": "2", "_index": "test_index", "_score": 1.0, "_source": {"fields": {"target": "VALUE"}, "some_key": "value"}, "_type": "_doc"},
         {"_id": "3", "_index": "test_index", "_score": 1.0, "_source": {"fields": {"target": "VALUE TEST"}, "some_key": "value"}, "_type": "_doc"},
         {"_id": "4", "_index": "test_index", "_score": 1.0, "_source": {"fields": {"target": "VALUE SOME"}, "some_key": "value"}, "_type": "_doc"}],
"max_score": 1.0,
"total": {"relation": "eq", "value": 5}

I need to filter documents where fields.target matches only "VALUE" (2 of 5 documents).
How can I do that?
The preferable method is query_string, but if it is not possible, other types ok too.

Mapping:

{
"test_index": {
    "mappings": {
        "properties": {
            "fields": {"properties": {"target": {"fields": {"keyword": {"ignore_above": 256, "type": "keyword"}}, "type": "text"}}},
            "some_key": {"fields": {"keyword": {"ignore_above": 256, "type": "keyword"}}, "type": "text"}}
            }
        }
    }
}

Try to search on fields.target.keyword instead.

Wow, thank you.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.