Problems with context suggester, ES 1.5.2


(Craig Ching) #1

I am creating some test use cases for what we need using the context suggester. I can get a simple suggest to work and I can get a context suggest to work, but what I can't get to work is a simple suggest without context. I'm getting the following error:

BroadcastShardOperationFailedException[[services][0] ]; nested: ElasticsearchException[failed to execute suggest]; nested: ElasticsearchIllegalArgumentException[suggester[completion]  doesn't support field [context]]; 

Here's a test script:

#!/bin/sh
  
echo 'deleting index'
curl -X DELETE localhost:9200/services/ && echo

echo 'creating index'
curl -XPUT localhost:9200/services/ && echo

echo 'creating mapping'
curl -X PUT localhost:9200/services/_mapping/service -d '
{
    "service": {
        "properties": {
            "name": {
                "type" : "string"
            },
            "tag": {
                "type" : "string"
            },
            "suggest_field": {
                "type": "completion",
                "context": {
                    "color": {
                        "type": "category",
                        "path": "color_field",
                        "default": ["red", "green", "blue"]
                    }
                }
            }
        }
    }
}' && echo

echo 'indexing document'
curl -X PUT 'localhost:9200/services/service/1?refresh=true' -d '
{
    "name": "knapsack",
    "suggest_field": {
        "input": ["knacksack", "backpack", "daypack"],
        "context": {
            "color": ["red", "yellow"]
        }
    }
}' && echo

echo 'getting suggest without context'
curl -X POST localhost:9200/services/_suggest?pretty -d '
{
    "suggest" : {
        "text" : "kna",
        "completion" : {
            "field" : "suggest_field",
            "size": 10
        }
    }
}' && echo

echo 'getting suggest with context'
curl -X POST localhost:9200/services/_suggest?pretty -d '
{
    "suggest" : {
        "text" : "kna",
        "completion" : {
            "field" : "suggest_field",
            "size": 10,
            "context": {
                "color": "red"
            }
        }
    }
}' && echo

Can anyone see if I'm doing something wrong? Or are you only allowed to specify a context with the context suggester?


(Pascal Heitz) #2

I'm having the same problem. Have you figured out what was wrong?