Interface ElasticSearchClient

  • All Known Implementing Classes:
    ElasticSearchClientImpl

    public interface ElasticSearchClient
    Since:
    2019/12/29, 13:27
    Author:
    Hongwei
    • Method Detail

      • createShared

        static ElasticSearchClient createShared​(io.vertx.core.Vertx vertx,
                                                io.vertx.core.json.JsonObject options)
      • connected

        boolean connected()
      • getIndex

        io.vertx.core.json.JsonObject getIndex​(String index)
        get index information
        Parameters:
        index - name of index
        Returns:
        JsonObject for index information
      • createIndex

        io.vertx.core.json.JsonObject createIndex​(String index,
                                                  int numberOfShards,
                                                  int numberOfReplicas,
                                                  ConcurrentMap<String,​Class<?>> mappings)
        create index with settings and mappings
        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

        io.vertx.core.json.JsonObject updateIndex​(String index,
                                                  int numberOfShards,
                                                  int numberOfReplicas)
        delete index
        Parameters:
        index - name of index
        numberOfShards - number of shards
        numberOfReplicas - number of replicas
        Returns:
        JsonObject like below { "isAcknowledged": true }
      • updateIndex

        io.vertx.core.json.JsonObject updateIndex​(String index)
      • deleteIndex

        io.vertx.core.json.JsonObject deleteIndex​(String index)
        delete index by name
        Parameters:
        index - name of index
        Returns:
        JsonObject like below { "isAcknowledged": true }
      • getDocument

        io.vertx.core.json.JsonObject getDocument​(String index,
                                                  String documentId)
        get document by document id
        Parameters:
        index - name of index
        documentId - document id
        Returns:
        JsonObject like below { "index"; "", "id": "", "result": true / false, "data": {} }
      • createDocument

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

        Boolean createDocuments​(String index,
                                io.vertx.core.json.JsonArray documents)
      • createDocuments

        Boolean createDocuments​(String index,
                                io.vertx.core.json.JsonArray documents,
                                String keyField)
      • updateDocument

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

        Boolean updateDocuments​(String index,
                                io.vertx.core.json.JsonArray documents)
      • updateDocuments

        Boolean updateDocuments​(String index,
                                io.vertx.core.json.JsonArray documents,
                                String keyField)
      • deleteDocument

        io.vertx.core.json.JsonObject deleteDocument​(String index,
                                                     String documentId)
        delete document by document id
        Parameters:
        index - name of index
        documentId - document id
        Returns:
        JsonObject like below { "index"; "", "id": "", "result": true / false }
      • search

        io.vertx.core.json.JsonObject search​(io.vertx.core.json.JsonObject params)
        get search result from ElasticSearch by search text
        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

        io.vertx.core.json.JsonObject search​(io.vertx.core.json.JsonObject params,
                                             ConcurrentMap<String,​String> precisionMap)