Skip to content

Instantly share code, notes, and snippets.

@Lackoftactics
Last active February 9, 2018 15:07
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 Lackoftactics/14e0140d563855b42025c77b89bc9f40 to your computer and use it in GitHub Desktop.
Save Lackoftactics/14e0140d563855b42025c77b89bc9f40 to your computer and use it in GitHub Desktop.
elastic normalizers hell
curl -XGET 'localhost:9200/events/_analyze?pretty' -H 'Content-Type: application/json' -d'
{
"normalizer" : "sortable",
"text" : "Triathlon race "
}
'
curl -XPUT 'localhost:9200/events/' -H 'Content-Type: application/json' -d'
{
"settings": {"analysis":{"filter":{"ngram_small_filter":{"type":"nGram","min_gram":2,"max_gram":5},"ngram_medium_filter":{"type":"nGram","min_gram":3,"max_gram":20}},"analyzer":{"index_ngram_small_analyzer":{"type":"custom","tokenizer":"standard","filter":["lowercase","ngram_small_filter"]},"index_ngram_medium_analyzer":{"type":"custom","tokenizer":"standard","filter":["lowercase","ngram_medium_filter"]},"search_standard_analyzer":{"type":"custom","tokenizer":"standard","filter":["lowercase"]}},"normalizer":{"sortable":{"type":"custom","char_filter":[],"filter":["lowercase"]}}}},
"mappings": {
"event":{"properties":{"name":{"type":"text","analyzer":"index_ngram_medium_analyzer","search_analyzer":"search_standard_analyzer"},"exact_name":{"type":"keyword","normalizer":"sortable"},"description":{"type":"text","analyzer":"index_ngram_medium_analyzer","search_analyzer":"search_standard_analyzer"},"distance":{"type":"text","analyzer":"index_ngram_small_analyzer","search_analyzer":"search_standard_analyzer"},"event_date":{"type":"date"},"searchable":{"type":"boolean"},"spotlight":{"type":"boolean"}}}
}
'
curl -XPUT 'localhost:9200/events/' -H 'Content-Type: application/json' -d'
{
"settings":{
"analysis":{
"filter":{
"ngram_small_filter":{
"type":"nGram",
"min_gram":2,
"max_gram":5
},
"ngram_medium_filter":{
"type":"nGram",
"min_gram":3,
"max_gram":20
},
"custom_trim":{
"type":"pattern_capture",
"preserve_original":false,
"patterns":[
"^ *([Ww]*)\b *$"
]
}
},
"analyzer":{
"index_ngram_small_analyzer":{
"type":"custom",
"tokenizer":"standard",
"filter":[
"lowercase",
"ngram_small_filter"
]
},
"index_ngram_medium_analyzer":{
"type":"custom",
"tokenizer":"standard",
"filter":[
"lowercase",
"ngram_medium_filter"
]
},
"search_standard_analyzer":{
"type":"custom",
"tokenizer":"standard",
"filter":[
"lowercase"
]
}
},
"normalizer":{
"sortable":{
"type":"custom",
"char_filter":[
],
"filter":[
"lowercase",
"trim_custom"
]
}
}
}
},
"mappings":{
"event":{
"properties":{
"exact_name":{
"type":"keyword",
"normalizer":"sortable"
}
}
}
}
}
'
curl -XDELETE 'localhost:9200/events/' -H 'Content-Type: application/json'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment