类 ElasticsearchBaseClient<T extends BaseT>
java.lang.Object
com.abasecode.opencode.es.ElasticsearchBaseClient<T>
- 作者:
- Jon e-mail: ijonso123@gmail.com url: Jon's blog url: project github url: AbaseCode.com
-
字段概要
字段修饰符和类型字段说明private co.elastic.clients.elasticsearch.ElasticsearchClientprivate static final Stringprivate ElasticsearchConfig.EsConfigprivate static final Integerprivate static final Integerprivate static final Stringprivate co.elastic.clients.transport.rest_client.RestClientTransport -
构造器概要
构造器构造器说明ElasticsearchBaseClient(co.elastic.clients.elasticsearch.ElasticsearchClient client, co.elastic.clients.transport.rest_client.RestClientTransport transport) InstantiationInstantiation -
方法概要
修饰符和类型方法说明booleancreateIndex(String index, String indexJson) create index by jsonbooleancreateIndexByJsonFile(String index, String jsonPath) create index by json fileprivate voidcreateQueryScript(String scriptId, String scriptSource, String language) create scriptvoidcreateQueryScript(String scriptId, String scriptSource, String language, boolean force) create scriptprivate voidcreate simple script templateco.elastic.clients.elasticsearch.core.BulkResponsedeleteBulkWithList(String index, List<String> ids) delete doc by listdelete doc by idbooleandeleteIndex(String index) delete indexbooleandeleteScriptById(String scriptId) delete script templateList<co.elastic.clients.elasticsearch._types.aggregations.HistogramBucket>getHistogramBucketByJson(String index, String aggregationJson, String aggName) get histogramBucket by jsonco.elastic.clients.elasticsearch.core.SearchRequestgetSearchRequest(String index, String json, org.springframework.data.domain.PageRequest pageRequest) get searchRequest by jsonprivate co.elastic.clients.elasticsearch.core.SearchResponse<Void>getSearchResponse(String index, String json, org.springframework.data.domain.PageRequest pageRequest) get searchResponseco.elastic.clients.elasticsearch.core.SearchResponse<T>getSearchResponse(String index, String json, org.springframework.data.domain.PageRequest pageRequest, Class<T> clazz) get searchResponse by jsonList<co.elastic.clients.elasticsearch._types.aggregations.StringTermsBucket>getStringTermsBucketByJson(String index, String aggregationJson, String aggName) get stringTermsBucket by jsongetSuggestionsByJson(String index, String suggestionJson, String suggestName) get suggestion sets by jsonbooleanhasDocExist(String index, String id) Check if the doc existsbooleanhasIndexExist(String index) check if the index existsbooleanhasScriptExist(String scriptId) check script existquery by idqueryByJson(String index, String json, Class<T> clazz) query by jsonorg.springframework.data.domain.Page<T>query by json with pageorg.springframework.data.domain.Page<T>queryByJsonWithPage(String index, String json, org.springframework.data.domain.PageRequest pageRequest, Class<T> clazz) query by json with pagequery by keyword simple matchqueryByScriptTemplate(String index, String scriptId, Map<String, co.elastic.clients.json.JsonData> map, Class<T> clazz) query by script templatequeryByScriptTemplate(Function<co.elastic.clients.elasticsearch.core.SearchTemplateRequest.Builder, co.elastic.clients.util.ObjectBuilder<co.elastic.clients.elasticsearch.core.SearchTemplateRequest>> fn, Class<T> clazz) query by script templatequery by simple script templatequeryFieldsByJson(String index, String json) query fields by json.queryFieldsByJsonWithPage(String index, String json, Integer pageNum, Integer pageSize) query by json with page notice: Json must specify the fields to be returnedqueryFieldsByJsonWithPage(String index, String json, org.springframework.data.domain.PageRequest pageRequest) query fields by json with page notice: Json must specify the fields to be returnedprivate StringsaveOrUpdateDoc(String index, T t) save or upate by TsaveOrUpdateDoc(String index, T t, boolean hasForce) save or update by Tco.elastic.clients.elasticsearch.core.BulkResponsesaveOrUpdateDocBulkWithJson(String index, List<String> jsons) save or update doc by listco.elastic.clients.elasticsearch.core.BulkResponsesaveOrUpdateDocBulkWithJsonFiles(String index, String path) save or update doc by bulk mode Note: json needs to be configured with idco.elastic.clients.elasticsearch.core.BulkResponsesaveOrUpdateDocBulkWithList(String index, List<T> list) save or update doc by Listprivate StringsaveOrUpdateDocByJson(String index, String json, String id) save or update docsaveOrUpdateDocByJson(String index, String json, String id, Boolean hasForce) save or update docprivate StringsaveOrUpdateDocByJsonFile(String index, String file, String id) save or update doc by json filesaveOrUpdateDocByJsonFile(String index, String file, String id, Boolean hasForce) save or update doc by json fileprivate co.elastic.clients.elasticsearch.core.UpdateByQueryResponseupdateByQuery(String index, String json) get UpdateByQueryResponseupdateByQueryWithJson(String index, String json) update by query with json
-
字段详细资料
-
构造器详细资料
-
ElasticsearchBaseClient
Instantiation -
ElasticsearchBaseClient
public ElasticsearchBaseClient(co.elastic.clients.elasticsearch.ElasticsearchClient client, co.elastic.clients.transport.rest_client.RestClientTransport transport) Instantiation- 参数:
client- ElasticsearchClienttransport- RestClientTransport
-
-
方法详细资料
-
hasIndexExist
check if the index exists- 参数:
index- index- 返回:
- boolean
- 抛出:
IOException
-
createIndex
create index by json- 参数:
index-indexJson-- 返回:
- boolean
- 抛出:
IOException
-
createIndexByJsonFile
create index by json file- 参数:
index-jsonPath-- 返回:
- boolean
- 抛出:
IOException
-
deleteIndex
delete index- 参数:
index-- 返回:
- boolean
- 抛出:
IOException
-
hasDocExist
Check if the doc exists- 参数:
index- indexid- doc id- 返回:
- boolean
- 抛出:
IOException
-
deleteDoc
delete doc by id- 参数:
index- indexid- doc id- 返回:
- string : deleted or not_found
- 抛出:
IOException
-
deleteBulkWithList
public co.elastic.clients.elasticsearch.core.BulkResponse deleteBulkWithList(String index, List<String> ids) throws IOException delete doc by list- 参数:
index- indexids- list- 返回:
- BulkResponse
- 抛出:
IOException
-
saveOrUpdateDocByJson
public String saveOrUpdateDocByJson(String index, String json, String id, Boolean hasForce) throws IOException save or update doc- 参数:
index- indexjson- jsonid- idhasForce- has force- 返回:
- String,updated or created
- 抛出:
IOException
-
saveOrUpdateDocByJson
save or update doc- 参数:
index- indexjson- jsonid- doc id- 返回:
- String,updated or created
- 抛出:
IOException
-
saveOrUpdateDocByJsonFile
public String saveOrUpdateDocByJsonFile(String index, String file, String id, Boolean hasForce) throws IOException save or update doc by json file- 参数:
index- indexfile- fileid- doc idhasForce- has force- 返回:
- String,updated or created
- 抛出:
IOException
-
saveOrUpdateDocByJsonFile
save or update doc by json file- 参数:
index- indexfile- fileid- doc id- 返回:
- String,updated or created
- 抛出:
IOException
-
saveOrUpdateDoc
save or update by T- 参数:
index- indext- ThasForce-- 返回:
- String,updated or created
- 抛出:
IOException
-
saveOrUpdateDoc
save or upate by T- 参数:
index- indext- T- 返回:
- String,updated or created
- 抛出:
IOException
-
saveOrUpdateDocBulkWithJsonFiles
public co.elastic.clients.elasticsearch.core.BulkResponse saveOrUpdateDocBulkWithJsonFiles(String index, String path) throws IOException save or update doc by bulk mode Note: json needs to be configured with id- 参数:
index- indexpath- path- 返回:
- BulkResponse
- 抛出:
IOException
-
saveOrUpdateDocBulkWithJson
public co.elastic.clients.elasticsearch.core.BulkResponse saveOrUpdateDocBulkWithJson(String index, List<String> jsons) throws IOException save or update doc by list- 参数:
index- indexjsons- json list- 返回:
- BulkResponse
- 抛出:
IOException
-
saveOrUpdateDocBulkWithList
public co.elastic.clients.elasticsearch.core.BulkResponse saveOrUpdateDocBulkWithList(String index, List<T> list) throws IOException save or update doc by List- 参数:
index- indexlist- lsit T- 返回:
- BulkResponse
- 抛出:
IOException
-
getSearchResponse
private co.elastic.clients.elasticsearch.core.SearchResponse<Void> getSearchResponse(String index, String json, org.springframework.data.domain.PageRequest pageRequest) throws IOException get searchResponse- 参数:
index- indexjson- json- 返回:
- SearchResponse
- 抛出:
IOException
-
getSearchResponse
public co.elastic.clients.elasticsearch.core.SearchResponse<T> getSearchResponse(String index, String json, org.springframework.data.domain.PageRequest pageRequest, Class<T> clazz) throws IOException get searchResponse by json- 参数:
index- indexjson- jsonpageRequest- pageRequest, nullableclazz- class- 返回:
- SearchResponse
- 抛出:
IOException
-
getSearchRequest
public co.elastic.clients.elasticsearch.core.SearchRequest getSearchRequest(String index, String json, org.springframework.data.domain.PageRequest pageRequest) get searchRequest by json- 参数:
index- indexjson- jsonpageRequest- pageRequest, nullable- 返回:
- SearchRequest
-
queryById
query by id- 参数:
index- indexid- idclazz- class- 返回:
- T
- 抛出:
IOException
-
queryByKeywordSimple
public List<T> queryByKeywordSimple(String index, String field, String keyword, Class<T> clazz) throws IOException query by keyword simple match- 参数:
index- indexfield- fieldkeyword- keywordclazz- class- 返回:
- List
- 抛出:
IOException
-
queryByJson
query by json- 参数:
index- indexjson- jsonclazz- class- 返回:
- List
- 抛出:
IOException
-
queryFieldsByJson
public List<Map<String,co.elastic.clients.json.JsonData>> queryFieldsByJson(String index, String json) throws IOException query fields by json. notice: Json must specify the fields to be returned- 参数:
index- indexjson- json- 返回:
- List<Map<String, JsonData>>
- 抛出:
IOException
-
queryByJsonWithPage
public org.springframework.data.domain.Page<T> queryByJsonWithPage(String index, String json, org.springframework.data.domain.PageRequest pageRequest, Class<T> clazz) throws IOException query by json with page- 参数:
index- indexjson- jsonpageRequest- pageRequestclazz- class- 返回:
- Page
- 抛出:
IOException
-
queryByJsonWithPage
public org.springframework.data.domain.Page<T> queryByJsonWithPage(String index, String json, Integer pageNum, Integer pageSize, Class<T> clazz) throws IOException query by json with page- 参数:
index- indexjson- jsonpageNum- pageNumpageSize- pageSizeclazz- class- 返回:
- Page
- 抛出:
IOException
-
queryFieldsByJsonWithPage
public org.springframework.data.domain.Page<Map<String,co.elastic.clients.json.JsonData>> queryFieldsByJsonWithPage(String index, String json, org.springframework.data.domain.PageRequest pageRequest) throws IOException query fields by json with page notice: Json must specify the fields to be returned- 参数:
index- indexjson- jsonpageRequest- pageRequest- 返回:
- Page
- 抛出:
IOException
-
queryFieldsByJsonWithPage
public org.springframework.data.domain.Page<Map<String,co.elastic.clients.json.JsonData>> queryFieldsByJsonWithPage(String index, String json, Integer pageNum, Integer pageSize) throws IOException query by json with page notice: Json must specify the fields to be returned- 参数:
index- indexjson- jsonpageNum- pageNumpageSize- pageSize- 返回:
- Page
- 抛出:
IOException
-
getStringTermsBucketByJson
public List<co.elastic.clients.elasticsearch._types.aggregations.StringTermsBucket> getStringTermsBucketByJson(String index, String aggregationJson, String aggName) throws IOException get stringTermsBucket by json- 参数:
index- indexaggregationJson- jsonaggName- agg name- 返回:
- set
- 抛出:
IOException
-
getSuggestionsByJson
public Set<String> getSuggestionsByJson(String index, String suggestionJson, String suggestName) throws IOException get suggestion sets by json- 参数:
index- indexsuggestionJson- suggestion jsonsuggestName- suggest name- 返回:
- Set
- 抛出:
IOException
-
getHistogramBucketByJson
public List<co.elastic.clients.elasticsearch._types.aggregations.HistogramBucket> getHistogramBucketByJson(String index, String aggregationJson, String aggName) throws IOException get histogramBucket by json- 参数:
index- indexaggregationJson- aggregationJsonaggName- agg name- 返回:
- List
- 抛出:
IOException
-
createQueryScript
public void createQueryScript(String scriptId, String scriptSource, String language, boolean force) throws IOException create script- 参数:
scriptId- script idscriptSource- script source, Content of sourcelanguage- script languageforce- has force- 抛出:
IOException
-
createQueryScript
private void createQueryScript(String scriptId, String scriptSource, String language) throws IOException create script- 参数:
scriptId- script idscriptSource- script templatelanguage- language- 抛出:
IOException
-
createSimpleScriptTemplate
create simple script template- 抛出:
IOException
-
hasScriptExist
check script exist- 参数:
scriptId- scriptId- 返回:
- boolean
- 抛出:
IOException
-
deleteScriptById
delete script template- 参数:
scriptId-- 返回:
- boolean
- 抛出:
IOException
-
queryBySimpleTemplate
public List<T> queryBySimpleTemplate(String index, String field, String value, Class<T> clazz) throws IOException query by simple script templateDSL example: GET /product/_search/template { "id":"es-simple-script", "params": { "field":"title", "value":"大米" } }
- 参数:
index- indexfield- fieldvalue- valueclazz- class- 返回:
- list
- 抛出:
IOException
-
queryByScriptTemplate
public List<T> queryByScriptTemplate(Function<co.elastic.clients.elasticsearch.core.SearchTemplateRequest.Builder, co.elastic.clients.util.ObjectBuilder<co.elastic.clients.elasticsearch.core.SearchTemplateRequest>> fn, Class<T> clazz) throws IOExceptionquery by script template- 参数:
fn- fnclazz- class- 返回:
- list
- 抛出:
IOException
-
queryByScriptTemplate
public List<T> queryByScriptTemplate(String index, String scriptId, Map<String, co.elastic.clients.json.JsonData> map, Class<T> clazz) throws IOExceptionquery by script template- 参数:
index- indexscriptId- scriptIdmap- mapclazz- class- 返回:
- List
- 抛出:
IOException
-
updateByQueryWithJson
update by query with jsonDSL example first: create script PUT /_scripts/price_add { "script":{ "lang": "painless", "source": "ctx._source.price += params.value" } } and then: POST /product/_update_by_query { "query": { "match_all": {} }, "script": { "id": "price_add", "params": { "value": 5 } } } all price will be increased by 5 java code reference test
- 参数:
index- indexjson- json- 返回:
- Long
- 抛出:
IOException
-
updateByQuery
private co.elastic.clients.elasticsearch.core.UpdateByQueryResponse updateByQuery(String index, String json) throws IOException get UpdateByQueryResponse- 参数:
index- indexjson- json- 返回:
- UpdateByQueryResponse
- 抛出:
IOException
-