gpt4 book ai didi

elasticsearch - 什么是等效于WHERE状态= 'DONE' AND badgeId IN的 Elasticsearch DSL( 'ID1', 'ID2', 'ID3')

转载 作者:行者123 更新时间:2023-12-03 00:49:11 24 4
gpt4 key购买 nike

我想编写与以下内容等效的 flex 搜索DSL查询:
SELECT * FROM awards WHERE status='DONE' AND badgeId IN ('ID1','ID2','ID3')
其中badgeId是奖项中的产品类型。status描述奖项中产品的状态。

索引图如下

{
"awards": {
"aliases": {},
"mappings": {
"_doc": {
"properties": {
"badgeId": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"blockchainAwardId": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"blockchainBadgeId": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"creatorPermission": {
"properties": {
"isPublic": {
"type": "boolean"
}
}
},
"dbCreateTime": {
"type": "long"
},
"dbUpdateTime": {
"type": "long"
},
"email": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"evidence": {
"properties": {
"audience": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"description": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"genre": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"link": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"narrative": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"exists": {
"type": "boolean"
},
"id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"isAwarded": {
"type": "boolean"
},
"isDeleted": {
"type": "boolean"
},
"isRevoked": {
"type": "boolean"
},
"orgId": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"recipientName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"status": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"timestamp": {
"type": "long"
},
"uid": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
},
"settings": {
"index": {
"number_of_shards": "3",
"provided_name": "awards",
"creation_date": "1557735146607",
"store": {
"type": "niofs"
},
"unassigned": {
"node_left": {
"delayed_timeout": "5m"
}
},
"number_of_replicas": "2",
"uuid": "mXkj_6BkQwOwIiAsNiHBXQ",
"version": {
"created": "6020299"
}
}
}
}
}

最佳答案

您可以这样做:

POST collection/_search
{
"query": {
"bool": {
"filter": [
{
"term" : {"status.keyword": "DONE" }
},
{
"terms" : {"badgeId.keyword": ["TYPE_1", "TYPE_2", "TYPE_3"] }
}
]
}
}
}

关于elasticsearch - 什么是等效于WHERE状态= 'DONE' AND badgeId IN的 Elasticsearch DSL( 'ID1', 'ID2', 'ID3'),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56021313/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com