2
筛选使用另一个查询的查询给出的例子用户和产品文档如下:如何在ElasticSearch
{
"_id": "1",
"_type": "user",
"_source": {
"id": "1",
"following": ["2", "3", ... , "10000"]
}
{
"_id": "1",
"_type": "product",
"_source": {
"id": "1",
"owner_id": "2"
}
{
"_id": "2",
"_type": "product",
"_source": {
"id": "2",
"owner_id": "10001"
}
我想要得到属于被随后与ID = 1的用户谁的用户的产品。我不想做2个不同的查询(首先让用户跟随用户id = 1,然后再获取产品),因为用户id = 1是跟随〜10000个用户。
有没有什么办法只用一个查询来得到结果呢?
号你想要一个内连接。这在ES中是不可能的。查看其他选项:https://www.elastic.co/guide/en/elasticsearch/guide/current/relations.html –