搜索 API
GET /<index>/_search POST /<index>/_search GET /_search POST /_search
示例:
# 单个索引: GET /twitter/_search?q=tag:wow # 多个索引: GET /kimchy,elasticsearch/_search?q=user:kimchy # 全部索引: GET /_search?q=user:kimchy GET /_all/_search?q=user:kimchy GET /*/_search?q=user:kimchy
URI Search
GET /<index>/_search?q=<parameter>
指定字段
GET /movies/_search?q=title:2012 { "profile":"true" }
泛查询
GET /movies/_search?q=2012 { "profile":"true" }
phrase 查询
GET /movies/_search?q=title:"Beautiful Mind" { "profile":"true" }
分组查询(非泛查询
GET /movies/_search?q=title:(Beautiful Mind) { "profile":"true" }
boolean 查询
GET /movies/_search?q=title:(Beautiful AND Mind) { "profile":"true" } GET /movies/_search?q=title:(Beautiful NOT Mind) { "profile":"true" } GET /movies/_search?q=title:(Beautiful %2BMind) { "profile":"true" }
通配符查询
GET /movies/_search?q=title:b* { "profile":"true" }
模糊查询
GET /movies/_search?q=title:beautifl~1 { "profile":"true" } GET /movies/_search?q=title:"Lord Rings"~2 { "profile":"true" }
范围查询,区间写法
GET /movies/_search?q=title:beautiful AND year:[2002 TO 2018%7D { "profile":"true" }
相关文档
https://www.elastic.co/guide/en/elasticsearch/reference/7.6/search-uri-request.html