Skip to content

Instantly share code, notes, and snippets.

@sameek
Created March 13, 2012 10:08
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 sameek/2027964 to your computer and use it in GitHub Desktop.
Save sameek/2027964 to your computer and use it in GitHub Desktop.
Custom Analyzer Setting
String analyzerSetting= " { \n" +
" \"index\" : {\n"+
"\"analysis\" : {\n"+
"\"analyzer\" : {\n"+
" \"mainindexanalyzer\" : {\n"+
"\"type\":\"custom\",\n"+
"\"tokenizer\" : \"whitespace\",\n"+
"\"filter\" : [\"lowercase\",\"asciifolding\",\"length\",\"mystopword\",\"mysynonym\",\"myworddelimiter\","\"myshingle\"],\n"+
"\"char_filter\" :[\"html_strip\"]\n"+
" },\n"+
"\"mainsearchanalyzer\" : {\n"+
"\"type\":\"custom\",\n"+
" \"tokenizer\" : \"whitespace\",\n"+
"\"filter\" : [\"lowercase\",\"asciifolding\",\"length\",\"mystopword\",\"mysynonym\",\"myworddelimiter\","\"myshingle\"],\n"+
"\"char_filter\" :[\"html_strip\"]\n"+
"}\n"+
"},\n"+
"\"filter\" : {\n"+
"\"mystopword\": {\n"+
" \"type\" : \"stop\",\n"+
"\"stopwords_path\" :\"F:/resources/stopwordeng.txt\" ,\n"+
"\"ignore_case\":true\n"+
"},\n"+
"\"mysynonym\": {\n"+
" \"type\" : \"synonym\",\n"+
"\"synonyms_path\" :\"F:/resources/synonym.txt\" ,\n"+
"\"ignore_case\":true\n"+
"},\n"+
"\"myworddelimiter\":{\n"+
" \"type\" : \"word_delimiter\",\n"+
"\"generate_word_parts\" :true ,\n"+
"\"split_on_case_change\":true ,\n"+
"\"catenate_all\":true\n"+
//"\"protected_words\" : [\",\",\"-\"],\n"+
//"\"catenate_all\":\n"+//protected_words
"}\n"+
"\"myshingle\":{\n"+
" \"type\" :\"shingle\",\n"+
"\"max_shingle_size\" :2,\n"+
"\"output_unigrams\":true \n"+
"}\n"+
"}\n"+
"}\n"+
"}\n"+
"}";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment