Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@masaruh
Created April 17, 2017 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masaruh/f217c26cf9b52ca71381b088f0e78630 to your computer and use it in GitHub Desktop.
Save masaruh/f217c26cf9b52ca71381b088f0e78630 to your computer and use it in GitHub Desktop.
################################
## THIS WORKS AS EXPECTED
################################
DELETE place
### create cat field as text type
PUT place
{
"mappings": {
"shops": {
"properties": {
"suggest": {
"type": "completion",
"contexts": [
{
"name": "place_type",
"type": "category",
"path": "cat"
}
]
},
"cat":{
"type": "text"
}
}
}
}
}
PUT place/shops/1
{
"suggest": ["timmy's", "starbucks", "dunkin donuts"],
"cat": ["cafe", "food"]
}
## This returns contexts "cafe" and "food" as expected
GET place/_search
{
"suggest": {
"place_suggestion": {
"prefix": "tim",
"completion": {
"field": "suggest",
"contexts": {
}
}
}
}
}
################################
## THIS DOESN'T WORK
################################
DELETE place
### create cat field as text type
PUT place
{
"mappings": {
"shops": {
"properties": {
"suggest": {
"type": "completion",
"contexts": [
{
"name": "place_type",
"type": "category",
"path": "cat"
}
]
},
"cat":{
"type": "keyword"
}
}
}
}
}
PUT place/shops/1
{
"suggest": ["timmy's", "starbucks", "dunkin donuts"],
"cat": ["cafe", "food"]
}
## This returns contexsts as null
GET place/_search
{
"suggest": {
"place_suggestion": {
"prefix": "tim",
"completion": {
"field": "suggest",
"contexts": {
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment