Skip to content

Instantly share code, notes, and snippets.

@zaiste
Last active August 29, 2015 14:05
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 zaiste/284b0cc96a07c6507d19 to your computer and use it in GitHub Desktop.
Save zaiste/284b0cc96a07c6507d19 to your computer and use it in GitHub Desktop.
# works
POST /movies/movie/_search
{
"query" : {
"match" : {
"inventory" : "MPA"
}
}
}
# works
POST /movies/movie/_search
{
"query": {
"query_string": {
"query": "MPA",
"fields": [
"inventory"
]
}
}
}
# doesn't work
POST /movies/movie/_search
{
"query": {
"query_string": {
"query": "MPA"
}
}
}
PUT /movies
{
"settings": {
"analysis": {
"filter": {
"ngram_filter": {
"type": "ngram",
"min_gram": 2,
"max_gram": 20 }
},
"analyzer": {
"index_ngram": {
"type": "custom",
"tokenizer": "keyword",
"filter": [
"lowercase",
"ngram_filter"
]
},
"search_ngram": {
"type": "custom",
"tokenizer": "keyword",
"filter": "lowercase"
}
}
}
},
"mappings": {
"movie": {
"properties": {
"inventory": {
"type": "string",
"analyzer": "index_ngram"
}
}
}
}
}
{
"movies": {
"mappings": {
"movie": {
"properties": {
"director": {
"type": "string"
},
"genres": {
"type": "string"
},
"inventory": {
"type": "string",
"analyzer": "index_ngram"
},
"title": {
"type": "string"
},
"year": {
"type": "long"
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment