Skip to content

Instantly share code, notes, and snippets.

@jakejscott
Created December 5, 2013 02:20
Show Gist options
  • Save jakejscott/7799153 to your computer and use it in GitHub Desktop.
Save jakejscott/7799153 to your computer and use it in GitHub Desktop.
Elastic search completion suggestor (run this in sense)
PUT music
PUT music/song/_mapping
{
"song": {
"properties": {
"name": {
"type": "string"
},
"suggest": {
"type": "completion",
"index_analyzer": "simple",
"search_analyzer": "simple",
"payloads": true
}
}
}
}
PUT music/song/1?refresh=true
{
"name": "Nevermind",
"suggest": {
"input": [
"Nevermind",
"Nirvana"
],
"output": "Nirvana - Nevermind",
"payload": {
"artistId": 2321
},
"weight": 34
}
}
POST music/_search
{
"suggest" : "Nirvana"
}
POST music/_suggest?pretty
{
"song-suggest" : {
"text" : "never",
"completion" : {
"field" : "suggest"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment