【发布时间】:2018-03-08 05:07:21
【问题描述】:
我有很多 产品 在 elasticsearch 中被索引。我需要从 elasticsearch 中的查询中排除一个 id 列表(我从 SQL 数据库中获取)。 假设 产品 存储为,
{
"id" : "1",
"name" : "shirt",
"size" : "xl"
}
我们使用弹性搜索根据某种算法向客户显示推荐产品列表。 如果客户将产品标记为“不感兴趣”,我们不必再次向他展示该产品。 我们将此类产品保存在单独的 SQL 表中,product_id、customer_id 和 status 为“not_interested”。
现在,在运行时为客户获取推荐时,我们从 SQL 数据库中获取“not_interested”产品列表,并在 elasticsearch 的非过滤器中发送 product_ids 数组以将它们排除在外推荐。 但是当 product_ids 数组的大小变得太大时,问题就出现了。
我应该如何在elasticsearch中存储product_id和customer_id映射 仅使用 elasticsearch 在运行时过滤掉“not_interested”产品?
将它们存储为嵌套对象或父/子文档是否有意义?或者一些完全其他的存储方式,这样我就可以有效地从结果中排除一些 id。
【问题讨论】:
标签: elasticsearch solr lucene elastic-stack recommendation-engine