Skip to content

Instantly share code, notes, and snippets.

@senthilsivanath
Last active March 20, 2016 18:06
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 senthilsivanath/97a9b4e4575d306887ea to your computer and use it in GitHub Desktop.
Save senthilsivanath/97a9b4e4575d306887ea to your computer and use it in GitHub Desktop.
Elastic Search Analyser setup for auto complete search with fuziness
{
"settings": {
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 15
}
},
"analyzer": {
"title_default_analyzer": {
"type": "custom",
"tokenizer":"standard",
"filter": ["lowercase", "asciifolding"]
},
"title_snowball_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": ["lowercase", "asciifolding", "snowball"]
},
"title_shingle_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": ["shingle", "lowercase", "asciifolding"]
},
"autocomplete": {
"type": "custom",
"tokenizer":"standard",
"filter": [
"lowercase",
"autocomplete_filter"
]
}
}
}
},
"mappings": {
"Album": {
"properties": {
"AlbumName": {"type": "string",
"fields":{
"raw": {"type": "string","analyzer": "title_default_analyzer"},
"snowball" : {"type":"string","analyzer": "title_snowball_analyzer"},
"shingle" : {"type":"string","analyzer": "title_shingle_analyzer"},
"autocomplete":{"type": "string","analyzer": "autocomplete"}
}
}
}
},
"Artist": {
"properties": {
"ArtistName": {"type": "string",
"fields":{
"raw": {"type": "string","analyzer": "title_default_analyzer"},
"snowball" : {"type":"string","analyzer": "title_snowball_analyzer"},
"shingle" : {"type":"string","analyzer": "title_shingle_analyzer"},
"autocomplete":{"type": "string","analyzer": "autocomplete"}
}
}
}
}
}
}
{
"query": {
"multi_match" : {
"fields" : ["AlbumName.raw^10","AlbumName.shingle^2","AlbumName.snowball^2","AlbumName.autocomplete"],
"query" : "kadhal",
"fuzziness" : "AUTO"
}
}
}
{
"query": {
"multi_match" : {
"fields" : ["ArtistName.raw^10","ArtistName.shingle^2","ArtistName.snowball^2","ArtistName.autocomplete"],
"query" : "vjiay",
"fuzziness" : "AUTO"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment