Created
April 18, 2012 23:22
-
-
Save ortschun/2417319 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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