# Context Suggester with keyword only field

**URL:** <https://discuss.elastic.co/t/context-suggester-with-keyword-only-field/73622>\
**Category:** Elasticsearch\
**Created:** [February 2, 2017, 4:02am UTC](https://discuss.elastic.co/t/context-suggester-with-keyword-only-field/73622 "2017-02-02T04:02:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![npow](https://avatars.discourse-cdn.com/v4/letter/n/e99b99/32.png) [@npow](https://discuss.elastic.co/u/npow)\
**Post date:** [February 2, 2017, 4:02am UTC](https://discuss.elastic.co/t/context-suggester-with-keyword-only-field/73622/1 "2017-02-02T04:02:37Z")

</div>

I'm trying to get the context suggester to work using a `keyword` field (ie not analyzed), but I can only get it to work with a `text` field. Changing the type of `user` from `keyword` to `text` will make the example below work. Is there a reason that the context suggester can only work on `text` fields?

PUT [http://localhost:9200/index-test](http://localhost:9200/index-test)

```auto
{
    "mappings": {
        "item" : {
            "properties" : {
            	"user": {
            		"type": "keyword"
            	},
                "keywords" : {
                    "type" : "completion",
                    "contexts": [
                        { 
                            "name": "user",
                            "type": "category",
                            "path": "user"
                        }
                    ]
                }
            }
        }
    }
}

```

PUT [http://localhost:9200/index-test/item/1](http://localhost:9200/index-test/item/1)

```auto
{
    "keywords": ["timmy's", "starbucks", "dunkin donuts"],
    "user": "abc"
}

```

```auto
{
  "suggest": {
    "keywords": {
      "prefix": "s",
      "completion": {
        "field": "keywords",
        "size": 10,
        "contexts": {
          "user": "abc"
        }
      }
    }
  }
}

```

---

<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:** [March 2, 2017, 4:03am UTC](https://discuss.elastic.co/t/context-suggester-with-keyword-only-field/73622/2 "2017-03-02T04:03:22Z")

</div>

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