gpt4 book ai didi

elasticsearch - 我无法在没有属性的Elasticsearch中进行查询。<字段名称>

转载 作者:行者123 更新时间:2023-12-03 02:14:56 26 4
gpt4 key购买 nike

这是用于搜索的查询:

{ "query": {
"term": {"properties.subscriptionid": "test"
}
}
}
结果:
  
"hits": [
{
"_id": "ILojbHQB1164tHwpvfoc",
"_source": {
"properties": {
"subscriptionid": "test",
}
如果我使用:
{ "query": {
"term": {"subscriptionid": "test"
}
}
}
我没有任何结果。
索引映射:
  "mappings": {
"properties": {
"subscriptionid": {
"type": "keyword"
},
"resources":{
"type": "nested",
}
}
*已移除,以减少代码区

最佳答案

正如@Val指出的那样,您在问题中发布的索引映射中有些不匹配。请参阅terms query,以获得有关它的详细信息。
添加一个带有索引数据,映射(与问题中提到的相同)和搜索查询的工作示例。
索引映射:

{
"mappings": {
"properties": {
"resources": {
"type": "nested"
},
"subscriptionid": {
"type": "keyword"
}
}
}
}
索引数据:
{
"subscriptionid": "test",
"resources": [
{
"title": "elasticsearch"
}
]
}

{
"subscriptionid": "test"
}
搜索查询:
{
"query": {
"term": {
"subscriptionid": "test"
}
}
}
搜索结果:
"hits": [
{
"_index": "stof",
"_type": "_doc",
"_id": "1",
"_score": 0.2876821,
"_source": {
"subscriptionid": "test"
}
}
]
使用词条查询搜索嵌套类型的查询:
{
"query": {
"nested": {
"path": "resources",
"query": {
"bool": {
"must": [
{ "term": { "resources.title": "elasticsearch" } }
]
}
}
}
}
}
嵌套映射的搜索结果:
"hits": [
{
"_index": "stof",
"_type": "_doc",
"_id": "2",
"_score": 0.2876821,
"_source": {
"subscriptionid": "test",
"resources": [
{
"title": "elasticsearch"
}
]
}
}
]

关于elasticsearch - 我无法在没有属性的Elasticsearch中进行查询。<字段名称>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63787803/

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