Skip to content

Instantly share code, notes, and snippets.

@sameek
Created February 16, 2012 07:51
Show Gist options
  • Save sameek/1843065 to your computer and use it in GitHub Desktop.
Save sameek/1843065 to your computer and use it in GitHub Desktop.
{
"index" : {
"analysis" : {
"analyzer" : {
"manualindexanalyzer" : {
"type":"custom",
"tokenizer" : "whitespace",
"filter" : ["lowercase","asciifolding","length","myelision"],
"char_filter" :["html_strip"]
},
"manualsearchanalyzer" : {
"type":"custom",
"tokenizer" : "whitespace",
"filter" : ["lowercase","asciifolding","length","myelision"],
"char_filter" :["html_strip"]
}
},
"filter" : {
"myelision":{
"type" : "elision",
"articles" :["l", "m", "t", "qu", "n", "s", "j"]
}
}
}
}
}
Mapping :
{
"test_type" : {
"index_analyzer" : "manualindexanalyzer",
"search_analyzer" : "manualsearchanalyzer"
}
}
//used code for putting mapping
String indexName="idx_test";
String inddxType="test_type";
PutMappingResponse actionGet =
client.admin().indices().preparePutMapping(indexName).setType(indexType).se tSource(analyzerMapping).execute().actionGet();
boolean acknowledged = actionGet.getAcknowledged();
logger.debug("put mapping acknowledged::" + acknowledged);
///search request
QueryStringQueryBuilder querystring = new
QueryStringQueryBuilder(searchData).analyzer("manualsearchanalyzer");
SearchResponse searchResponse =
client.prepareSearch(indexName).setTypes(indexType).setSearchType(SearchTyp
e.DEFAULT)
.setQuery(querystring.field("Description")).setExplain(true).setSize(100).e
xecute().actionGet();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment