【问题标题】:Solr Query, Syntax trouble with drupal apache solr moduleSolr 查询,drupal apache solr 模块的语法问题
【发布时间】:2015-04-24 05:49:47
【问题描述】:

我正在使用 apache solr,以及 drupal 7 apachesolr 的模块。 我们的一些查询非常自定义。

我一直在查看 solr 文档和关于 stackoverflow 的解释。 我想出了一个查询:

/select?q=&start=0&rows=20&fq=bundle:(message)&fq=sm_hashtags:(hashtags)&fq=(is_uid:(1 OR 2 OR 37 OR 38 OR 50 OR 166 OR 174 OR 198 OR 431 OR 499 OR 640 OR 642) AND is_privacy:(0)) AND -is_uid:(177 OR 189) AND is_status:(1)&fq=entity_id:{* TO 2666}&fl=tus_message_object,sm_hashtags,content,ts_search,is_privacy,is_status,is_uid&sort=entity_id+desc&wt=json&wt=json

但这是返回 NULL,我尝试了一些不同的方法,例如:

/select?q=&start=0&rows=20&fq=bundle:(message)&fq=sm_hashtags:(hashtags)&fq=((is_uid:(1+OR+2+OR+37+OR+38+OR+50+OR+166+OR+174+OR+198+OR+431+OR+499+OR+640+OR+642)+is_privacy:(0))-is_uid:(177+OR+189)+is_status:(1))&fq=entity_id:{*+TO+2666}&fl=tus_message_object,sm_hashtags,content,ts_search,is_privacy,is_status,is_uid&sort=entity_id+desc&wt=json&wt=json

但我不确定这是否正确。

我需要一个过滤器,允许 id 为 (is_uid) 且所有隐私为 0 的用户,但不允许 id 列表 -is_uid 和状态为 1 的用户。

【问题讨论】:

    标签: apache solr drupal-7


    【解决方案1】:

    您使用了很多子句,因此很难在这里确定可能是什么原因。我可以给你以下提示:

    a) 调试模式
    复制整个查询字符串,转到 Solr 管理控制台并使用附加的 debug=true 或 debugQuery=true 执行该查询。在输出的响应中,Solr 将附加一个附加部分,其中解释了它如何“看到”您输入的查询

    b) 逐个调查每个 fq
    如果有问题,肯定是在过滤查询中,所以我建议你一个一个逐步尝试。但在此之前,请参见 c) 点。

    c) fq 设计
    过滤器查询的缓存功能非常棒。在这里,虽然我认为有些 fq 不会重复使用(is_uid 过滤器),但我建议您拆分这些查询以获得更好的可重复使用(即缓存)结果;类似:

    fq=bundle:message // You already have this
    fq=sm_hashtags:hashtags // You already have this
    fq=is_privacy:0 // this will cache (for further reuse) all documents with no privacy
    fq=is_status:1 // this will cache (for further reuse) all documents with status 1
    fq=is_uid(1 OR 921 OR 9...) // Most probably these query results won't benefit so much of caching. If so, I think this query could be also part of the main query
    fq=-is_uid(8 OR 99) // Most probably these query results won't benefit so much of caching. If so, I think this query could be also part of the main query
    

    【讨论】:

      【解决方案2】:

      您没有查询任何字段q=。试试q=*:*,或任何领域的任何东西。调试 solr 的最佳方法是在 solr 查询构建器中手动构建查询,通常是 http://localhost:8983/solr,然后查看返回的结果。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-11
        • 1970-01-01
        相关资源
        最近更新 更多