另一个查询中的Solr字段值?可能吗?

时间:2015-04-15 10:39:07

标签: solr nested subquery clause

我有这种类型的ouput genral

"docs": [
  {
    "id": "552e1acd5971b",
    "product_id": "NOT05253",
    "attribute_id": 0,
    "attribute_name": "Brend",
    "value_id": 12923,
    "value_name": "ACER",
    "category_id": 166,
    "_version_": 1498504104368930800
  },
  {
    "id": "552e1acd7d479",
    "product_id": "NOT05604",
    "attribute_id": 0,
    "attribute_name": "Brend",
    "value_id": 12923,
    "value_name": "ACER",
    "category_id": 166,
    "_version_": 1498504104523071500
  },
  {
    "id": "552e1acdc9c7c",
    "product_id": "NOT05988",
    "attribute_id": 0,
    "attribute_name": "Brend",
    "value_id": 12923,
    "value_name": "ACER",
    "category_id": 166,
    "_version_": 1498504104851275800
  },
  {
    "id": "552e1acdef261",
    "product_id": "NOT06361",
    "attribute_id": 0,
    "attribute_name": "Brend",
    "value_id": 12923,
    "value_name": "ACER",
    "category_id": 166,
    "_version_": 1498504105011708000
  }, ..... 

我尝试做的是获取结果,其中product_id匹配另一个查询中的一个product_id ...

category_id:166 AND value_id:12923
AND product_id:( _query_:"value_id:64 " )

我使用它来更快地进行EAV产品过滤,这个查询特别需要缩短ACER笔记本的product_id数量,以15.6"屏幕尺寸:)

另一个词 - 像SQL查询:

SELECT * FROM table WHERE value_id=12923 AND product_id IN (SELECT product_id FROM table WHERE value_id=64)

任何艰难的? :d

1 个答案:

答案 0 :(得分:0)

Solr有一些这里描述的连接功能[1]。它可能是你正在寻找的。
关于其他条款:我将使用过滤查询(即fq = value_id:12923)


[1] https://wiki.apache.org/solr/Join