gpt4 book ai didi

elasticsearch - 具有相同类型的 Elasticsearch 父级

转载 作者:行者123 更新时间:2023-11-29 02:48:33 24 4
gpt4 key购买 nike

抱歉,如果这是重复的(我确实尝试过搜索),或者这是一个愚蠢的问题。刚开始发布问题。

我正在尝试使用以下内容在 ElasticSearch 中进行父子关系和查询:

    #!/bin/bash

curl -XDELETE 'http://localhost:9200/test/'
echo

curl -XPUT 'http://localhost:9200/test/' -d '{
"settings" : {
"index" : {
"number_of_shards" : 1
}
}
}'
echo

curl -XPUT localhost:9200/test/_mapping/nelement -d '{
"nelement" : {
"_id" : { "path" : "nid", "store" : true, "index" : "not_analyzed"},
"_parent" : { "type" : "nelement"},
"properties" : {
"name" : { "type" : "string", "index" : "not_analyzed" },
"nid": { "type" : "string", "copy_to" : "_id" }
}
}
}'
echo

#curl -s -XPOST localhost:9200/_bulk --data-binary @test_data.json
test_data.json is as follows:
{"index":{"_index":"test","_type":"element", "_parent":"abc"}
{"nid":"1a","name":"parent1"}
{"index":{"_index":"test","_type":"element", "_parent":"1a"}
{"nid":"2b","name":"child1"}
{"index":{"_index":"test","_type":"element", "_parent":"2b"}
{"nid":"2c","name":"child2"}


curl -XGET 'localhost:9200/test/nelement/_search?pretty=true' -d '{

"query": {
"has_child": {
"child_type": "nelement",
"query": {
"match": {
"nid": "2c"
}
}
}
}

}'



echo
echo
curl -XGET 'localhost:9200/test/nelement/_search?pretty=true' -d '{

"query": {
"has_parent": {
"type": "nelement",
"query": {
"term": {
"nid": "2b"
}
}
}
}

}'

出于某种原因,我的搜索查询没有结果。我已确认对象已编入索引....

最佳答案

因为您正在使用自引用(在同一索引类型中设置父项和查询)到父/子查询。

目前 Elasticsearch 不支持它。

Explore parent/child self referential support

关于elasticsearch - 具有相同类型的 Elasticsearch 父级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31714777/

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