Skip to content

Instantly share code, notes, and snippets.

@rehia
Last active January 19, 2017 14:22
Show Gist options
  • Save rehia/ec4b97b025ddf495f2d898a260bf5e97 to your computer and use it in GitHub Desktop.
Save rehia/ec4b97b025ddf495f2d898a260bf5e97 to your computer and use it in GitHub Desktop.
Elasticsearch configuration for autocompletion search
{
settings: {
number_of_shards: 1,
analysis: {
filter: {
autocomplete_filter: {
type: 'ngram',
min_gram: 3,
max_gram: 15
}
},
analyzer: {
autocomplete: {
type: 'custom',
tokenizer: 'standard',
filter: [
'lowercase',
'autocomplete_filter'
]
}
}
}
},
mappings: {
[type]: {
properties: {
name: {
type: 'string',
fields: {
autocomplete: {
type: 'string',
analyzer: 'autocomplete',
search_analyzer: 'standard'
}
}
},
twitter_keywords: {
type: 'string',
fields: {
autocomplete: {
type: 'string',
analyzer: 'autocomplete',
search_analyzer: 'standard'
}
}
},
instagram_keywords: {
type: 'string',
fields: {
autocomplete: {
type: 'string',
analyzer: 'autocomplete',
search_analyzer: 'standard'
}
}
}
}
}
}
}
{
query: {
multi_match: {
query,
type: 'most_fields',
fields: [ '*_keywords^4', 'name^8', '*_keywords.autocomplete', 'name.autocomplete^2' ]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment