Created
June 29, 2011 10:35
-
-
Save alh3im/1053618 to your computer and use it in GitHub Desktop.
Ngram working sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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