首页  

elasticsearch5.0基于url的搜索接口     所属分类 elasticsearch 浏览量 1123
elasticsearch5.0基于url的搜索接口



根据原文翻译整理
https://www.elastic.co/guide/en/elasticsearch/reference/5.0/search-uri-request.html


A search request can be executed purely using a URI by providing request parameters. 

基于URL的搜索请求

GET twitter/tweet/_search?q=user:kimchy

http://127.0.0.1:9200/twitter/tweet/_search
http://127.0.0.1:9200/twitter/tweet/_search?q=user:kimchy
http://127.0.0.1:9200/twitter/tweet/_search?q=user:kimchy&_source=false
http://127.0.0.1:9200/twitter/tweet/_search?q=user:kimchy&_source=user,message

http://127.0.0.1:9200/twitter/tweet/_search?q=user:kimchy&sort=post_date:desc

http://127.0.0.1:9200/twitter/tweet/_search?q=user:kimchy&sort=post_date:desc&from=0&size=2

http://127.0.0.1:9200/twitter/tweet/_search?q=user:kimchy&sort=post_date:desc&from=1&size=2


/articles/_search?q=java%20linux&df=content&default_operator=and

/articles/_search?q=linux&df=category&sort=update_time
/articles/_search?q=linux&df=category&sort=update_time:desc


df
The default field to use when no field prefix is defined within the query.

default_operator
The default operator to be used, can be AND or OR. Defaults to OR




参数说明

q
The query string 

df
The default field to use when no field prefix is defined within the query.

analyzer
The analyzer name to be used when analyzing the query string.
查询串分析器


lowercase_expanded_terms
Should terms be automatically lowercased or not. Defaults to true.

analyze_wildcard
Should wildcard and prefix queries be analyzed or not. Defaults to false.
分析通配符和前缀查询

default_operator
The default operator to be used, can be AND or OR. Defaults to OR.

lenient
If set to true will cause format based failures 
(like providing text to a numeric field) to be ignored. Defaults to false.
宽容 
设置为true  格式不对会被忽略

explain
For each hit, contain an explanation of how scoring of the hits was computed.

_source
Set to false to disable retrieval of the _source field. 
You can also retrieve part of the document by using 
_source_include & _source_exclude 

_source=false  不返回 _source 
_source=user,message  只返回  user和message 这两个字段


是否返回_source字段 
如果要返回部分字段 实用 _source_include  _source_exclude 

stored_fields

The selective stored fields of the document to return for each hit, comma delimited. 
Not specifying any value will cause no fields to return.

sort
Sorting to perform. Can either be in the form of fieldName, 
or fieldName:asc/fieldName:desc. The fieldName can either be an actual field within the document, 
or the special _score name to indicate sorting based on scores. 
There can be several sort parameters (order is important).

sort=post_date:desc



track_scores
When sorting, set to true in order to still track scores 
and return them as part of each hit.

timeout

A search timeout, bounding the search request to be executed 
within the specified time value 
and bail with the hits accumulated up to that point when expired. 
Defaults to no timeout.



terminate_after
The maximum number of documents to collect for each shard, 
upon reaching which the query execution will terminate early. 
If set, the response will have a boolean field terminated_early 
to indicate whether the query execution has actually terminated_early. 
Defaults to no terminate_after.
每个分片返回文档最大个数

from
The starting from index of the hits to return. Defaults to 0.

size
The number of hits to return. Defaults to 10.

分页查询参数 from  size 

search_type
The type of the search operation to perform. 
Can be dfs_query_then_fetch or query_then_fetch. 
Defaults to query_then_fetch. 
See Search Type for more details on the different types of search that can be performed.

分布式搜索  排名 和 size 

搜索类型详解
https://www.elastic.co/guide/en/elasticsearch/reference/5.0/search-request-search-type.html

上一篇     下一篇
linux之grep命令

elasticsearch5.0搜索API概述

elasticsearch5.0搜索API使用概述

新东方年会《释放自我》歌词

elasticsearch5.0使用RequestBody搜索接口

科创板首批人工智能公司信息