Skip to content

Instantly share code, notes, and snippets.

@kimchy
Created September 27, 2010 20:31
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 kimchy/599771 to your computer and use it in GitHub Desktop.
Save kimchy/599771 to your computer and use it in GitHub Desktop.
public class TestMe {
public static void main(String[] args) throws Exception {
NodeBuilder nb = NodeBuilder.nodeBuilder().client(true);
Node node = nb.node();
Client client = node.client();
XContentBuilder content = XContentFactory.smileBuilder().startObject();
content.field("indexid", "index21");
content.field("documentkey", "532-UMSACT0420100927111149CMCSA-20100927111149");
content.field("subtransid", "3072773936");
content.field("dmsourceid", "index21");
content.field("documentdate", "index21");
content.field("documenttag", "WSMarketCommentary_15884843");
content.field("documenttype", "MarketCommentary");
content.field("feedid", "532");
content.field("versiontag", "20100927111516");
content.field("bridgesymbols", "");
content.field("headline", "S&P Market Commentary");
content.field("productcategory", "MarketCommentary");
content.field("publicationdatetime", "2010-09-27 11:15:16.000");
content.field("source", "SNPMarketScope");
content.field("teaser", "");
content.field("wsodcompany", "");
content.field("wsodissue", "");
content.endObject();
client.prepareIndex("rebuild_index21", "index21", "532-UMSACT0420100927111149CMCSA-20100927111149")
.setSource(content).setOperationThreaded(false).execute()
.actionGet();
client.admin().indices().prepareRefresh().execute().actionGet();
SearchResponse response = client.prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet();
for (SearchHit hit : response.hits()) {
System.out.println("" + hit.sourceAsMap());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment