gpt4 book ai didi

elasticsearch - ElasticSearch查询搜索消息并限制为节点ID

转载 作者:行者123 更新时间:2023-12-03 02:09:47 25 4
gpt4 key购买 nike

我在ElasticSearch中具有以下映射:

{
"xenforo" : {
"post" : {
"_source" : {
"enabled" : false
},
"properties" : {
"date" : {
"type" : "long",
"store" : "yes"
},
"discussion_id" : {
"type" : "long",
"store" : "yes"
},
"message" : {
"type" : "string"
},
"node" : {
"type" : "long"
},
"thread" : {
"type" : "long"
},
"title" : {
"type" : "string"
},
"user" : {
"type" : "long",
"store" : "yes"
}
}
},

我想在消息字段中搜索单词test,但将其限制为节点ID5。如何修改此DSL搜索?
$data_string = '{
"from" : 0, "size" : 100,
"sort" : [
{ "date" : {"order" : "desc"} }
],
"query": {
"match" : {
"message" : {
"query" : "test"
}
}
}
}';

谢谢您的协助。

最佳答案

您可以使用filtered查询:

{
"from": 0,
"size": 100,
"sort": [{
"date": {
"order": "desc"
}
}],
"query": {
"filtered": {
"query": {
"match": {
"message": {
"query": "test"
}
}
},
"filter": {
"term": {
"node": 5
}
}
}
}
}

关于elasticsearch - ElasticSearch查询搜索消息并限制为节点ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15994410/

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