集成

public TransportClient client(){
    InetSocketTransportAddress node =new InetSocketTransportAddress(
    InetAddress.getByName("localhost"),9300);
    Setting settrings=Settings.builder().put("cluster.name","wali").build();
    TransportClient client=new PreBuiltTransportClient(Settings,EMPTY);
    client.addTransportAddress(node);
    return client;
}

获取

GetResponnse result=this.client.preprareGet("book","novel",id).setSource().get();

增加

XcontentFactory.jsonBuilder()
.startObject()
.field("title",title)
.field("author",author)
.field("word_count",wordCount)
.field("publist_data",publishData.getTime())
.endObject();
result=this.client.preprareGet("book","novel",id).setSource().get();

删除

this.client.prepareDelete("book",)

更新接口

Last updated

Was this helpful?