Context Suggester with keyword only field


(npow) #1

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

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

PUT http://localhost:9200/index-test/item/1

{
    "keywords": ["timmy's", "starbucks", "dunkin donuts"],
    "user": "abc"
}
{
  "suggest": {
    "keywords": {
      "prefix": "s",
      "completion": {
        "field": "keywords",
        "size": 10,
        "contexts": {
          "user": "abc"
        }
      }
    }
  }
}

Context Suggester Using Keyword Field
(system) #2

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