Skip to content

Instantly share code, notes, and snippets.

@alh3im
Created June 29, 2011 10:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alh3im/1053618 to your computer and use it in GitHub Desktop.
Save alh3im/1053618 to your computer and use it in GitHub Desktop.
Ngram working sample
// Config
{
"index" : {
"analysis" : {
"filter" : {
"my_ngram" : {
"max_gram" : 20,
"min_gram" : 2,
"type" : "nGram"
}
},
"analyzer" : {
"lowercase_keyword" : {
"filter" : [
"standard",
"lowercase"
],
"type" : "custom",
"tokenizer" : "standard"
},
"lowercase_keyword_ngram" : {
"filter" : [
"standard",
"lowercase",
"my_ngram"
],
"type" : "custom",
"tokenizer" : "standard"
}
}
}
}
}
// Mapping
{
"mapping": {
"properties": {
"title": {
"type": "string",
"indexAnalyzer": "lowercase_keyword_ngram",
"searchAnalyzer": "lowercase_keyword"
}
}
}
}
// Data
{
"title": "please search me"
}
// Query
{
"query": {
"query_string": {
"default_field": "title",
"default_operator": "AND",
"query": "ase se"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment