全部匹配match_all
方式一
GET /website/_search
GET /website/_search
{
"query":{
"match_all": {
}
}
}
模糊查询match
或查询
GET /website/_search
{
"query":{
"match": {
"text":{
"query":"Just blog",
"operator": "or"
}
}
}
}
GET /website/_search
{
"query":{
"match": {
"text":"Just blog"
}
}
}
与查询
--- Just和blog都存在才匹配
GET /website/_search
{
"query":{
"match": {
"text":{
"query":"Just blog",
"operator": "or"
}
}
}
}
匹配精度
---50% 即三个词中有一个匹配即可
GET /website/_search
{
"query":{
"match": {
"text":{
"query":"Just blo1g 1out",
"minimum_should_match": "50%"
}
}
}
}
term
查询(查询内容不会被分词)
与match的区别
match_phrase
query_string
排序
示例
GET /website/_search
{
"query": {
"query_string": {
"fields": [
"title"
],
"query": "first blog"
}
},
"sort": [
{
"date": {
"order": "desc"
}
}
]
}
分页
示例
GET /website/_search
{
"query": {
"query_string": {
"fields": [
"title"
],
"query": "first blog"
}
},
"sort": [
{
"date": {
"order": "desc"
}
}
],
"from": 0,
"size": 2
}
显示指定字段
示例
GET /website/_search
{
"query": {
"query_string": {
"fields": [
"title"
],
"query": "first blog"
}
},
"_source": [
"text",
"title"
]
}
高亮
示例
GET /website/_search
{
"query": {
"query_string": {
"fields": [
"title"
],
"query": "first blog"
}
},
"highlight": {"fields": {"title": {}}}
}
其他的用到的时候再补充.....