ElasticSearch 的IN查詢
{
"query":{
"bool": {
"must": [
{
"match_all":{}
},
{
"terms": {
"goods_id": [1,2,3]
}
}
]
}
}
}
{
"from": 0,
"query": {
"bool": {
"must": [{
"multi_match": {
"fields": ["goods_name", "brand"],
"query": "北京測試商品001-3",
"type": "most_fields"
}
}]
}
},
"size": 100,
"sort": {
"price": {
"order": "desc"
},
"views": {
"order": "desc"
}
}
}
ElasticSearch 的 NOT IN 查詢
{
"query":{
"bool": {
"must": [
{
"match_all":{}
}
]
},
"must_not"[
{
"terms":
{
"goods_id": [1,2,3]
}
}]
}
]
}
}
ElasticSearch 分頁、排序以及多欄位匹配查詢
{
"from": 0,
"query": {
"bool": {
"must": [{
"multi_match": {
"fields": ["goods_name", "brand"],
"query": "北京測試商品001-3",
"type": "most_fields"
}
},
{
"terms": {
"goods_id": [6]
}
}]
}
},
"size": 100,
"sort": {
"mall_sort_order": {
"order": "desc"
},
"sales": {
"order": "desc"
}
}
}
ElasticSearch 按照單個欄位算分從高到低進行排序
{
"from": 0,
"query": {
"bool": {
"must": [{
"multi_match": {
"fields": ["goods_name", "brand"],
"query": "神經系統",
"type": "best_fields"
}
}]
}
},
"size": 100,
"sort": {
"_score":{
"order": "desc"
}
}
}
等同於
POST dev_shop_index/_search
{
"query":{
"dis_max" : {
"queries":[
{
"match":{
"goods_name" : "神經系統"
}
},
{
"match" : {
"brand" : "神經系統"
}
}
}
]
}
}
}
等同於
{
"query": {
"multi_match": {
"fields": ["goods_name", "brand"],
"query": "神經系統",
"type": "best_fields"
}
}
}
本作品採用《CC 協議》,轉載必須註明作者和本文連結