Skip to content

Instantly share code, notes, and snippets.

@clintongormley
Created March 11, 2014 11:19
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 clintongormley/9483845 to your computer and use it in GitHub Desktop.
Save clintongormley/9483845 to your computer and use it in GitHub Desktop.
curl -XPUT "http://localhost:9200/production_index" -d'
{
"mappings": {
"production": {
"properties": {
"production_title": {
"type": "multi_field",
"fields": {
"production_title_edgengram": {
"type": "string",
"index": "analyzed",
"index_analyzer": "autocomplete_index",
"search_analyzer": "autocomplete_search"
},
"production_title": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
},
"settings": {
"analysis": {
"filter": {
"ngram_filter": {
"max_gram": "8",
"min_gram": "2",
"type": "nGram"
},
"autocomplete_ngram": {
"side": "front",
"max_gram": "15",
"min_gram": "1",
"type": "edgeNGram"
}
},
"analyzer": {
"autocomplete_search": {
"filter": "lowercase",
"tokenizer": "keyword"
},
"ngram_index": {
"filter": [
"ngram_filter"
],
"tokenizer": "keyword"
},
"autocomplete_index": {
"filter": [
"lowercase",
"autocomplete_ngram"
],
"tokenizer": "keyword"
},
"ngram_search": {
"filter": "lowercase",
"tokenizer": "keyword"
}
}
}
}
}'
curl -XPUT "http://localhost:9200/production_index/production/1" -d'
{
"production_title": "IL, \"Hoodoo Love\""
}'
curl -XGET "http://localhost:9200/production_index/production/_search" -d'
{
"query": {
"term": {
"production_title": "IL, \"Hoodoo Love\""
}
}
}'
curl -XGET "http://localhost:9200/production_index/production/_search" -d'
{
"query": {
"match": {
"production_title_edgengram": "Il"
}
},
"sort": [
{
"production_title": "asc"
}
]
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment