# Keyword typed field partially matching user query

**URL:** <https://discuss.elastic.co/t/keyword-typed-field-partially-matching-user-query/348033>\
**Category:** Elasticsearch\
**Created:** [November 27, 2023, 10:03am UTC](https://discuss.elastic.co/t/keyword-typed-field-partially-matching-user-query/348033 "2023-11-27T10:03:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![spino17](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spino17/32/120694_2.png) [@spino17](https://discuss.elastic.co/u/spino17)\
**Post date:** [November 27, 2023, 10:03am UTC](https://discuss.elastic.co/t/keyword-typed-field-partially-matching-user-query/348033/1 "2023-11-27T10:03:25Z")

</div>

I am using ES 7.9 version.  
I have a category index with document like

```auto
doc_1 = { "value": "laptops" }
doc-2 = { "value": "air cooler" }

```

with following schema:

```auto
{
    "mappings": {
        "properties": {
            "value": {
                "type": "keyword"
            }
        }
    }
}

```

I am recognising the category inside a user query by using `match` query on the `value` field of this index.  
When I have a query: `LG TV 55 inch with air play`, it is matching with a category doc

```auto
{ "value": "air cooler" }

```

which should not happen as in schema if I have used `keyword` type, it should be treated as a single token and hence should not partially match with user-query.  
I want that a document in category index only matches if that complete value is contained inside the user-query for example: a query like `LG smart air cooler` and not for `LG TV 55 inch with air play`.

I am new to ES and might be modelling the query completely wrong, however stuck on this for very long and any help in the right direction is appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 25, 2023, 10:04am UTC](https://discuss.elastic.co/t/keyword-typed-field-partially-matching-user-query/348033/2 "2023-12-25T10:04:21Z")

</div>

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