【问题标题】:Is Solr 4.0 capable of using 'join" for multiple core?Solr 4.0 是否能够对多核使用“加入”?
【发布时间】:2016-03-23 17:19:31
【问题描述】:

我注意到 Solr 4.0 为具有关系的文档引入了“加入”功能。这很好,但是,我注意到http://wiki.apache.org/solr/Join 给出的示例是针对单核的,所有文档都在单个索引中。

有人知道我是否可以对多核使用“加入”吗?

【问题讨论】:

    标签: join solr lucene


    【解决方案1】:

    This comment 表示可以使用:

    {!join from=fromField to=toField fromIndex=fromCoreName}fromQuery
    

    我自己试过了,这里有一个更详细的例子: 有两个核心

    • 品牌{id,name}
    • 产品 {id, name, brand_id}

    品牌:{1,Apple},{2,Samsung},{3,HTC}

    产品:{1, iPhone, 1}, {2, iPad, 1}, {3, Galaxy S3, 2}, {4, Galaxy Note, 2}, {5, One X, 3}

    http://example.com:8999/solr/brands/select?q=*:*&fq={!join from=brand_id to=id fromIndex=products}name:iPad

    这翻译成这样的:

    SELECT b.* FROM brands b
           INNER JOIN products p ON b.id=p.brand_id
           WHERE p.name="iPad";
    

    结果将是:{id:"1", name:"Apple"}

    【讨论】:

    • 感谢这个很好的例子。更准确地说,SQL 等价物是 SELECT b.* FROM brands b INNER JOIN products p ON b.id=p.brand_id WHERE p.name="iPad";,因为 Solr 不能给出 fromCore 的字段:-(
    • 查询无效,应该是:q=name:iPad&fq={!join from=brand_id to=id fromIndex=products}q=*:*&fq={!join from=brand_id to=id fromIndex=products}name:iPadq=: 无效。
    • @zengr:是的,: 显示为格式化选项,现在已修复。
    • 如果 products.id 是一个 id 数组,是否可以这样做?
    • @Adam 我相信是的,是的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-11
    • 2021-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多