分布式全文搜索引擎ES

匿名 (未验证) 提交于 2019-12-03 00:04:02

                                ES

什么是ES文档操作:

  1.ES(document oriented)(document)(index)ES

   GET _search

  

DSLDSL

 

 

ES

 

 

Node:  

 

       master Node:,

 

       data  node:,  crud

 

       client node:

 

 

1- 在生产环境下,如果不修改ElasticSearch节点的角色信息,在高数据量,高并发的场景下集群容易出现脑裂等问题

 

 

 23masternode.master: true node.data: false       

 

    3datanode.master: false node.data: true 

 

    4clientnode.master: false node.data: true 

 

<dependency>

 

    <groupId>org.elasticsearch.client</groupId>

 

    <artifactId>transport</artifactId>

 

    <version>5.2.2</version>

 

</dependency>

 

<dependency>

 

    <groupId>org.apache.logging.log4j</groupId>

 

    <artifactId>log4j-api</artifactId>

 

    <version>2.7</version>

 

</dependency>

 

<dependency>

 

    <groupId>org.apache.logging.log4j</groupId>

 

    <artifactId>log4j-core</artifactId>

 

    <version>2.7</version>

 

</dependency>

 

Settings settings = Settings.builder()

 

        .put("client.transport.sniff", true).build();

 

TransportClient client = new PreBuiltTransportClient(settings);

 

 

import static org.elasticsearch.common.xcontent.XContentFactory.*;

 

IndexResponse response = client.prepareIndex("crm", "vip", "1")

 

.setSource(jsonDataText).get();

 

 

GetResponse response = client.prepareGet("crm", "vip", "1").get();

 

client.prepareUpdate("crm", "vip", "1").setDoc("{\"sex\":0}").get();

 

client.prepareUpdate("crm", "vip", "1")

 

.setScript(new Script("ctx._source.sex = 1"  , ScriptService.ScriptType.INLINE,null, null))

 

            .get();

 

IndexRequest indexRequest = new IndexRequest("crm", "vip", "1")

 

.source(originalJsonData);

 

UpdateRequest updateRequest = new UpdateRequest("crm", "vip", "1")

 

.doc(updateJsonData).upsert(indexRequest);

 

client.update(updateRequest).get();

 

 

DeleteResponse response = client.prepareDelete("crm", "vip", "1").get();

 

 

BulkRequestBuilder bulkRequest = client.prepareBulk();

 

bulkRequest.add(client.prepareIndex("crm", "vip", "1")

 

.setSource(vip1JsonData));

 

bulkRequest.add(client.prepareIndex("crm", "vip", "2")

 

.setSource(vip2JsonData));

 

BulkResponse bulkResponse = bulkRequest.get();

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!