Skip to content

Instantly share code, notes, and snippets.

@ortschun
Created April 18, 2012 23:22
Show Gist options
  • Save ortschun/2417319 to your computer and use it in GitHub Desktop.
Save ortschun/2417319 to your computer and use it in GitHub Desktop.
n = NodeBuilder.nodeBuilder().build().start();
c = n.client();
Map<String, Object> storemapping = new HashMap<String, Object>();
storemapping.put("type", "string");
storemapping.put("store", "yes");
storemapping.put("analyzer", "simplealphanum");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("store", storemapping);
Map<String, Object> mappings = new HashMap<String, Object>();
mappings.put("properties", properties);
c.admin()
.indices()
.preparePutMapping("c")
.setType("mappingtest")
.setSource(XContentFactory.jsonBuilder().startObject().field("testmapping", mappings).endObject()).execute().actionGet();
AnalyzeResponse rsvp = c.admin().indices().prepareAnalyze("THIS_is IS A123 45 t-0 133[orcun] ?TEST").setIndex("c").setField("store").execute().actionGet();
for(AnalyzeToken token : rsvp.getTokens()){
System.out.println(token.getTerm());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment