Class ElasticSearchClientImpl

java.lang.Object
io.vertx.tp.plugin.elasticsearch.ElasticSearchClientImpl
All Implemented Interfaces:
ElasticSearchClient

public class ElasticSearchClientImpl extends Object implements ElasticSearchClient
Since:
2019/12/29, 13:31
Author:
Hongwei
  • Method Details

    • connected

      public boolean connected()
      Specified by:
      connected in interface ElasticSearchClient
    • getIndex

      public io.vertx.core.json.JsonObject getIndex(String index)
      Description copied from interface: ElasticSearchClient
      get index information
      Specified by:
      getIndex in interface ElasticSearchClient
      Parameters:
      index - name of index
      Returns:
      JsonObject for index information
    • deleteIndex

      public io.vertx.core.json.JsonObject deleteIndex(String index)
      Description copied from interface: ElasticSearchClient
      delete index by name
      Specified by:
      deleteIndex in interface ElasticSearchClient
      Parameters:
      index - name of index
      Returns:
      JsonObject like below { "isAcknowledged": true }
    • createIndex

      public io.vertx.core.json.JsonObject createIndex(String index, ConcurrentMap<String,Class<?>> mappings)
      Specified by:
      createIndex in interface ElasticSearchClient
    • createIndex

      public io.vertx.core.json.JsonObject createIndex(String index, int numberOfShards, int numberOfReplicas, ConcurrentMap<String,Class<?>> mappings)
      Description copied from interface: ElasticSearchClient
      create index with settings and mappings
      Specified by:
      createIndex in interface ElasticSearchClient
      Parameters:
      index - name of index. this is real index name
      numberOfShards - number of shards, default is 3
      numberOfReplicas - number of replicas, default is 2
      mappings - fields were used to create index mapping
      Returns:
      JsonObject like below { "isAcknowledged": true }
    • updateIndex

      public io.vertx.core.json.JsonObject updateIndex(String index)
      Specified by:
      updateIndex in interface ElasticSearchClient
    • updateIndex

      public io.vertx.core.json.JsonObject updateIndex(String index, int numberOfShards, int numberOfReplicas)
      Description copied from interface: ElasticSearchClient
      delete index
      Specified by:
      updateIndex in interface ElasticSearchClient
      Parameters:
      index - name of index
      numberOfShards - number of shards
      numberOfReplicas - number of replicas
      Returns:
      JsonObject like below { "isAcknowledged": true }
    • createDocument

      public io.vertx.core.json.JsonObject createDocument(String index, String documentId, io.vertx.core.json.JsonObject source)
      Description copied from interface: ElasticSearchClient
      create document from json object, must specify document id
      Specified by:
      createDocument in interface ElasticSearchClient
      Parameters:
      index - name of index
      documentId - document id
      source - json object of document
      Returns:
      JsonObject like below { "index"; "", "id": "", "result": true / false }
    • createDocuments

      public Boolean createDocuments(String index, io.vertx.core.json.JsonArray documents)
      Specified by:
      createDocuments in interface ElasticSearchClient
    • createDocuments

      public Boolean createDocuments(String index, io.vertx.core.json.JsonArray documents, String keyField)
      Specified by:
      createDocuments in interface ElasticSearchClient
    • getDocument

      public io.vertx.core.json.JsonObject getDocument(String index, String documentId)
      Description copied from interface: ElasticSearchClient
      get document by document id
      Specified by:
      getDocument in interface ElasticSearchClient
      Parameters:
      index - name of index
      documentId - document id
      Returns:
      JsonObject like below { "index"; "", "id": "", "result": true / false, "data": {} }
    • updateDocument

      public io.vertx.core.json.JsonObject updateDocument(String index, String documentId, io.vertx.core.json.JsonObject source)
      Description copied from interface: ElasticSearchClient
      update document from json object, must specify document id
      Specified by:
      updateDocument in interface ElasticSearchClient
      Parameters:
      index - name of index
      documentId - document id
      source - json object of document
      Returns:
      JsonObject like below { "index"; "", "id": "", "result": true / false }
    • updateDocuments

      public Boolean updateDocuments(String index, io.vertx.core.json.JsonArray documents)
      Specified by:
      updateDocuments in interface ElasticSearchClient
    • updateDocuments

      public Boolean updateDocuments(String index, io.vertx.core.json.JsonArray documents, String keyField)
      Specified by:
      updateDocuments in interface ElasticSearchClient
    • deleteDocument

      public io.vertx.core.json.JsonObject deleteDocument(String index, String documentId)
      Description copied from interface: ElasticSearchClient
      delete document by document id
      Specified by:
      deleteDocument in interface ElasticSearchClient
      Parameters:
      index - name of index
      documentId - document id
      Returns:
      JsonObject like below { "index"; "", "id": "", "result": true / false }
    • deleteDocuments

      public Boolean deleteDocuments(String index, Set<String> ids)
      Specified by:
      deleteDocuments in interface ElasticSearchClient
    • search

      public io.vertx.core.json.JsonObject search(io.vertx.core.json.JsonObject params)
      Description copied from interface: ElasticSearchClient
      get search result from ElasticSearch by search text
      Specified by:
      search in interface ElasticSearchClient
      Parameters:
      params - params will be used to search, format likes below { "index": "", --- required "searchText": "", --- required "from": 0, --- default is 0 "size": 10 --- default is 10 }
      Returns:
      JsonObject like below { "status": "OK", "took": 1, "aggregations": [ { "key": "cmdb", "doc_count": 10 }, ... ], "total": 10, "hits": [ { "_index": "aaa", "_type": "_doc", "_id": "2", "_score": 1.1507283, "_source": {}, "highlight": {} }, ... ] }
    • search

      public io.vertx.core.json.JsonObject search(io.vertx.core.json.JsonObject params, ConcurrentMap<String,String> precisionMap)
      Specified by:
      search in interface ElasticSearchClient