ElasticSearch中Java Search API
2017-07-14 13:48
399 查看
原文地址:https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-search.html
Java
API [5.5] » Search API
«
Using Bulk Processor Using
scrolls in Java »
The search API allows one to execute a search query and get back search hits that match the query. It can be executed across one or more indices and across one or more types. The query can be provided using the query
Java API. The body of the search request is built using the
Here is an example:
Note that all parameters are optional. Here is the smallest search call you can write:
Although the Java API defines the additional search types QUERY_AND_FETCH and DFS_QUERY_AND_FETCH, these modes are internal optimizations and should not be specified explicitly by users of the API.
For more information on the search operation, check out the REST search docs.
«
Using Bulk Processor Using
scrolls in Java »
Java
API [5.5] » Search API
«
Using Bulk Processor Using
scrolls in Java »
Search APIedit
The search API allows one to execute a search query and get back search hits that match the query. It can be executed across one or more indices and across one or more types. The query can be provided using the queryJava API. The body of the search request is built using the
SearchSourceBuilder.
Here is an example:
import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.index.query.QueryBuilders.*;
SearchResponse response = client.prepareSearch("index1", "index2") .setTypes("type1", "type2") .setSearchType(SearchType.DFS_QUERY_THEN_FETCH) .setQuery(QueryBuilders.termQuery("multi", "test")) // Query .setPostFilter(QueryBuilders.rangeQuery("age").from(12).to(18)) // Filter .setFrom(0).setSize(60).setExplain(true) .get();
Note that all parameters are optional. Here is the smallest search call you can write:
// MatchAll on the whole cluster with all default options SearchResponse response = client.prepareSearch().get();
Although the Java API defines the additional search types QUERY_AND_FETCH and DFS_QUERY_AND_FETCH, these modes are internal optimizations and should not be specified explicitly by users of the API.
For more information on the search operation, check out the REST search docs.
«
Using Bulk Processor Using
scrolls in Java »
相关文章推荐
- ElasticSearch JAVA API基础学习------Elasticsearch学习(二)
- 【工作笔记】ElasticSearch从零开始学(五)—— Java_SearchAPI
- elasticsearch常用的java API
- elasticsearch的javaAPI之query
- ElasticSearch 6.x 学习笔记:31.Java API之词项查询
- Elasticsearch java API (26) Indices 指标管理
- ElasticSearch API for JAVA 学习笔记
- ElasticSearch的Java Api基本操作入门指南
- [ElasticSearch]Java API 之 索引文档 (Index API)
- Elasticsearch的javaAPI之query dsl-queries
- ElasticSearch的Java Api基本操作入门指南
- ElasticSearch java API--创建mapping
- elasticsearch 2.3.4 java API 连接,ik分词器,设置集群节点,创建index,mapping的几种方式
- Elasticsearch Java API(八)--搜索有相同父id的子文档
- ElasticSearch 6.x 学习笔记:28.Java API之文档批量操作
- 【工作笔记】ElasticSearch从零开始学(四)—— Java_DocumentAPI(CRUD)
- Elasticsearch的javaAPI之get,delete,bulk
- ElasticSearch Java API
- Elasticsearch java API (20)查询 DSL
- ElasticSearch的javaAPI之Client