Tyler James Leonhardt
Tyler James Leonhardt

Reputation: 884

Is there a way to have multiple completion suggesters on a single index?

Here is my index:

{
"mappings": {
    "packages" : {
        "properties" : {
            "suggest-name" : {
                "type" : "completion"
            },
            "suggest-tags" : {
                "type" : "completion"
            },
            "suggest-cmdlets" : {
                "type" : "completion"
            }
        }
    }
}
}

I would love to be able to something like this:

curl -XPOST 'localhost:32769/test/_search?pretty&pretty' -H 'Content-Type: application/json' -d'
{
    "suggest": {
        "packages-suggest" : {
            "prefix" : "get",
            "completion" : {
                "fields" : ["suggest-cmdlet", "suggest-name", "suggest-tags"]
            }
        }
    }
}
'

and specify all the fields I want to try to look at for the autocomplete.

This doesn't seem to be the right way to do it... How would you reference multiple fields in an autocomplete search query?

Thanks for the help!

Upvotes: 0

Views: 452

Answers (1)

Val
Val

Reputation: 217464

You need to do it like this:

curl -XPOST 'localhost:32769/test/_search?pretty&pretty' -H 'Content-Type: application/json' -d'
{
    "suggest": {
        "packages-suggest-1" : {
            "prefix" : "get",
            "completion" : {
                "field" : "suggest-cmdlets"
            }
        },
        "packages-suggest-2" : {
            "prefix" : "get",
            "completion" : {
                "field" : "suggest-name"
            }
        },
        "packages-suggest-3" : {
            "prefix" : "get",
            "completion" : {
                "field" : "suggest-tags"
            }
        }
    }
}
'

Upvotes: 3

Related Questions