# Term Query on Keyword type which is part of a completion context did not work

**URL:** https://discuss.elastic.co/t/term-query-on-keyword-type-which-is-part-of-a-completion-context-did-not-work/232197
**Category:** Elasticsearch
**Created:** [May 12, 2020, 10:20am UTC](https://discuss.elastic.co/t/term-query-on-keyword-type-which-is-part-of-a-completion-context-did-not-work/232197 "2020-05-12T10:20:26Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![alexisvisco](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexisvisco/32/68140_2.png) [@alexisvisco](https://discuss.elastic.co/u/alexisvisco)
#### Post date: [May 12, 2020, 10:20am UTC](https://discuss.elastic.co/t/term-query-on-keyword-type-which-is-part-of-a-completion-context-did-not-work/232197/1 "2020-05-12T10:20:26Z")

</div>

Hi community, I have a problem with a property named "hash" which is of type "keyword". This property is also used for a completion category context.

ElasticSearch Version: [docker.elastic.co/elasticsearch/elasticsearch-oss:7.6.2](http://docker.elastic.co/elasticsearch/elasticsearch-oss:7.6.2)

The mapping of the index is:

```auto
{
  "mappings": {
    "properties": {
      "hash": {
        "type": "keyword"
      },
      "value": {
        "type": "completion",
        "contexts": [
          {
            "name": "hash",
            "type": "category",
            "path": "hash"
          }
        ]
      }
    }
  }
}

```

The index contain this document:

```auto
{
   "_index":"values_completion",
   "_type":"_doc",
   "_id":"e044c078f773f973e441125dc0b61e4d",
   "_score":1.0,
   "_source":{
      "hash":"439ad864081de8cd6b28763b5c43566e",
      "value":{
         "input":[
            "92"
         ]
      }
   }
}

```

The query I am attempting to do is:

```auto
{
	"query": {
		"term": {
			"hash": "439ad864081de8cd6b28763b5c43566e"
		}
	},
	"size": 10
}

```

I got no results from ElasticSearch ...

```auto
{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 100,
      "relation": "eq"
    },
    "max_score": 2.4103107,
    "hits": []
  }
}

```

Is it possible that the keyword type is not indexed as keyword due to the completion context ?

Thanks you for your time 🙂

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [May 12, 2020, 12:30pm UTC](https://discuss.elastic.co/t/term-query-on-keyword-type-which-is-part-of-a-completion-context-did-not-work/232197/2 "2020-05-12T12:30:01Z")

</div>

Welcome!

It sounds like that your request actually returns 100 hits:

```
"total": {
  "value": 100,
  "relation": "eq"
},

```

What makes you think that it does not work?

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem.

---

<div class="post-metadata">

### Author: ![alexisvisco](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexisvisco/32/68140_2.png) [@alexisvisco](https://discuss.elastic.co/u/alexisvisco)
#### Post date: [May 12, 2020, 2:00pm UTC](https://discuss.elastic.co/t/term-query-on-keyword-type-which-is-part-of-a-completion-context-did-not-work/232197/3 "2020-05-12T14:00:41Z")

</div>

Okay you are right, I was manipulating the size in parameter URL and in the body. In addition in my code I was using the wrong index haha so the hash wasn't the same.

Thanks you

---

<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: [June 9, 2020, 2:00pm UTC](https://discuss.elastic.co/t/term-query-on-keyword-type-which-is-part-of-a-completion-context-did-not-work/232197/4 "2020-06-09T14:00:44Z")

</div>

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