gpt4 book ai didi

elasticsearch - ElasticSearch has_child查询什么都找不到

转载 作者:行者123 更新时间:2023-12-02 23:39:21 26 4
gpt4 key购买 nike

我有一个问题,已为对象建立索引,但是在使用has_child搜索时,什么也不返回。

映射:

父级:

$ curl -XGET 'http://localhost:9200/items/article/_mapping?pretty'
"items" : {
"mappings" : {
"article" : {
"_meta" : {
"model" : "..."
},
"_source" : {
"enabled" : false,
"includes" : [ ],
"excludes" : [ ]
},
"properties" : {
"content" : {
"type" : "string",
"store" : true,
"analyzer" : "app_standard",
"fields" : {
"transliterated" : {
"type" : "string",
"analyzer" : "transliteration"
},
"stemmed" : {
"type" : "string",
"analyzer" : "app_text_analyzer"
}
}
}
,...
}
}
}
}

子级:
$ curl -XGET 'http://localhost:9200/items/comment/_mapping?pretty'
"items" : {
"mappings" : {
"comment" : {
"_meta" : {
"model" : "..."
},
"_parent" : {
"type" : "article"
},
"_routing" : {
"required" : true,
"path" : "article_id"
},
"_source" : {
"enabled" : false,
"includes" : [ ],
"excludes" : [ ]
},
"properties" : {
"article_id" : {
"type" : "long",
"store" : true
}
,...
}
}
}
}

父文档和子文档都存在:

上级:
$ curl -XGET 'http://localhost:9200/items/article/110700879894'

结果:
{
"_index": "items",
"_type": "article",
"_id": "110700879894",
"_version": 1,
"found": true
}

没有路由的子节点失败:
$ curl -XGET 'http://localhost:9200/items/comment/110700879894.110700879894'

结果:
{
"error": "RoutingMissingException[routing is required for [items]/[comment]/[110700879894.110700879894]]",
"status": 400
}

有路由的 child :
$ curl -XGET 'http://localhost:9200/items/comment/110700879894.110700879894?parent=110700879894'

结果:
{
"_index": "items",
"_type": "comment",
"_id": "110700879894.110700879894",
"_version": 1,
"found": true
}

但是has_child什么也没找到:
$ curl -XGET 'http://localhost:9200/items/article/_search' -d '{
"query": {
"has_child": {
"type": "comment",
"query": {
"term": {
"article_id": "110700879894"
}
}
}
}
}'

结果:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}

也有has_parent:
$ curl -XGET 'http://localhost:9200/items/comment/_search' -d '{
"query": {
"has_parent": {
"type": "article",
"query": {
"match_all": {}
}
}
}
}'

结果:
{
"took": 232,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}

我的猜测是索引编制中有些混乱,未设置父子关系。但另一方面,发现子级路由正确。

还是我只是在做错误的查询。

如何检查 parent 的子女文件?

编辑

索引要求:
PUT http://localhost:9200/_bulk
{"index":{"_index":"items","_type":"comment","_id":"110700879894.110700879894"}}
{"article_id":"110700879894",...}

这里不应该是 parent 吗?

最佳答案

documentation所写:

“默认情况下,_id不被索引和存储(因此,未创建)。

关于elasticsearch - ElasticSearch has_child查询什么都找不到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25100022/

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