elasticsearch - Elasticsearch获取父字段

标签 elasticsearch elastica

在我的索引中,我有两种类型的广告和产品,

产品名称:

_index: fadel
_type: product
_id: 103|2
_version: 1
_score: 1
_source: {
code: 35569058
manufacturer: Packard Bell
tax_class_id: [ ]
visibility: 4
price: [ ]
in_stock: 1
.....
....

广告
_index: fadel
_type: ads
_id: 92
_version: 1
_score: 1
_source: {
customer_id: 2
ads_id: 92
product_id: 28
price_current: 1200.0000
is_pro_customer: 0
state: 13
qty_current: 19
}
fields: {
_parent: 28|2
}

因此,我如何才能获得产品的所有广告,以及如何将相关产品检索到广告中

PS:1个产品可能有一个或多个广告,但与1个产品相关的广告

谢谢

最佳答案

_parent字段已被索引并存储,因此您可以将其用作任何其他字段。例如,您可以使用_parent字段进行搜索以检索给定产品的所有广告,也可以在_parent字段中检索值存储并使用Get操作来检索产品。

关于elasticsearch - Elasticsearch获取父字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14074185/

相关文章:

elasticsearch - 使用数组项作为键的ElasticSearch聚合

Elasticsearch 空闲时 CPU 高

elasticsearch - 弹性的UPSERT功能?

symfony - Elasticsearch PHP最长前缀匹配

php - Elasticsearch\RuntimeException:无法进行JSON编码:第33行的文件/Elasticsearch/Serializers/SmartSerializer.php中的5

ElasticSearch 将完整索引转储到 csv 文件

stored-procedures - ElasticSearch存储过程

twitter - 如果在Elasticsearch中使用批量处理器不存在索引

symfony - Elastica结果:搜索整个索引时如何获取原则对象

elasticsearch - ElasticSearch不会为常见查询字符串返回任何结果(使用不太常见的字符串)