gpt4 book ai didi

elasticsearch - 在ElasticSearch中查询动态对象类型

转载 作者:行者123 更新时间:2023-12-03 02:35:05 45 4
gpt4 key购买 nike

在模板中具有以下字段定义。

"details": {
"dynamic": "true",
"type": "object"
}

该字段是基于JSON模式动态设置的,下面是一个示例。
"details": {
"responses": [
{
"questionKind": "multiple_choice",
"text": "Request Subscription",
"questionOrder": 1,
"order": 1
}
]
}

是否可以查询ElasticSearch动态对象数据类型?我已经尝试了以下方法,但没有成功。
{
"query": {
"bool": {
"must": [
{
"match": {
"details.responses.questionKind": "multiple_choice"
}
}
]
}
}
}

完整索引模板:
{
"index_patterns": "sponsorshipsinfluencers*",
"order": 3,
"version": 3,
"aliases": {
"sponsorshipsinfluencers": {}
},
"settings": {
"number_of_shards": 5,
"analysis": {
"normalizer": {
"lowercase_normalizer": {
"type": "custom",
"char_filter": [],
"filter": [
"lowercase"
]
}
}
}
},
"mappings": {
"dynamic": "true",
"properties": {
"id": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
},
"influencerId": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
},
"campaignId": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
},
"campaignSponsorshipSetId": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
},
"campaignSponsorshipId": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
},
"acceptedDate": {
"type": "date"
},
"declinedDate": {
"type": "date"
},
"completedDate": {
"type": "date"
},
"paidDate": {
"type": "date"
},
"status": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
},
"campaignType": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
},
"createdTimestampEpochInMilliseconds": {
"type": "date",
"format": "epoch_millis",
"index": false
},
"updatedTimestampEpochInMilliseconds": {
"type": "date",
"format": "epoch_millis",
"index": false
},
"createdDate": {
"type": "date"
},
"updatedDate": {
"type": "date"
},
"details": {
"dynamic": "true",
"type": "object"
}
}
}
}

最佳答案

我会尝试使用details部分,它可能是文档类型名称:

{
"query": {
"bool": {
"must": [
{
"match": {
"responses.questionKind": "multiple_choice"
}
}
]
}
}
}

关于elasticsearch - 在ElasticSearch中查询动态对象类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59059146/

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