001/* 002 * (C) Copyright 2017 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * bdelbosc 018 */ 019package org.nuxeo.elasticsearch.api; 020 021import org.elasticsearch.action.bulk.BulkRequest; 022import org.elasticsearch.action.bulk.BulkResponse; 023import org.elasticsearch.action.delete.DeleteRequest; 024import org.elasticsearch.action.delete.DeleteResponse; 025import org.elasticsearch.action.get.GetRequest; 026import org.elasticsearch.action.get.GetResponse; 027import org.elasticsearch.action.index.IndexRequest; 028import org.elasticsearch.action.index.IndexResponse; 029import org.elasticsearch.action.search.ClearScrollRequest; 030import org.elasticsearch.action.search.ClearScrollResponse; 031import org.elasticsearch.action.search.SearchRequest; 032import org.elasticsearch.action.search.SearchResponse; 033import org.elasticsearch.action.search.SearchScrollRequest; 034import org.elasticsearch.cluster.health.ClusterHealthStatus; 035 036/** 037 * @since 9.3 038 */ 039public interface ESClient extends AutoCloseable { 040 041 // ------------------------------------------------------------------- 042 // Admin 043 // 044 boolean waitForYellowStatus(String[] indexNames, int timeoutSecond); 045 046 ClusterHealthStatus getHealthStatus(String[] indexNames); 047 048 void refresh(String indexName); 049 050 void flush(String indexName); 051 052 void optimize(String indexName); 053 054 boolean indexExists(String indexName); 055 056 boolean mappingExists(String indexName, String type); 057 058 void deleteIndex(String indexName, int timeoutSecond); 059 060 void createIndex(String indexName, String jsonSettings); 061 062 void createMapping(String indexName, String type, String jsonMapping); 063 064 String getNodesInfo(); 065 066 String getNodesStats(); 067 068 boolean aliasExists(String aliasName); 069 070 /** 071 * Returns the name of the index referenced by the alias. 072 * Returns null if the alias does not exists. 073 */ 074 String getFirstIndexForAlias(String aliasName); 075 076 void updateAlias(String aliasName, String indexName); 077 078 // ------------------------------------------------------------------- 079 // Search 080 // 081 082 BulkResponse bulk(BulkRequest request); 083 084 DeleteResponse delete(DeleteRequest request); 085 086 SearchResponse search(SearchRequest request); 087 088 SearchResponse searchScroll(SearchScrollRequest request); 089 090 GetResponse get(GetRequest request); 091 092 IndexResponse index(IndexRequest request); 093 094 ClearScrollResponse clearScroll(ClearScrollRequest request); 095 096}