简体   繁体   English

Solr查询,Drupal Apache Solr模块的语法问题

[英]Solr Query, Syntax trouble with drupal apache solr module

I'm working with apache solr, and the module for drupal 7 apachesolr. 我正在使用apache solr和drupal 7 apachesolr的模块。 Some of our queries are very custom. 我们的一些查询是非常自定义的。

I have been looking in the solr documentation and at explanations on stackoverflow. 我一直在寻找solr文档以及关于stackoverflow的解释。 I have come up with the query: 我提出了查询:

/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

but this is returning NULL, i have tried a few different things like: 但这返回了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

But I am not sure this is correct. 但是我不确定这是正确的。

I need a filter that allows the users with id (is_uid) and all the ones with privacy is 0 but not the users in blocked id list -is_uid and where the status is 1. 我需要一个过滤器,该过滤器允许具有ID(is_uid)的用户和所有具有隐私的用户为0,但不允许处于阻止ID列表-is_uid且状态为1的用户。

You're using a lot of clauses so it is very hard to determine here what could be the cause. 您使用了很多子句,因此很难在这里确定是什么原因。 I can give you the following hints: 我可以给您以下提示:

a) Debug mode a)调试模式
Copy the whole query string, go to the Solr Admin console and execute that query with and additional debug=true or debugQuery=true. 复制整个查询字符串,转到Solr管理控制台,并使用以及其他debug = true或debugQuery = true来执行该查询。 In the outcoming response, Solr will append an additional section where it explains how it "sees" the query you entered 在即将到来的响应中,Solr将附加一个附加部分,在该部分中说明如何“查看”您输入的查询

b) Investigate each fq one by one b)逐一调查每个fq
If there's a problem, it is for sure in the filter queries, so I suggest you to gradually try them one by one. 如果有问题,可以肯定是在过滤器查询中,所以建议您逐步尝试一下。 But before of that, see the c) point. 但在此之前,请参阅c)点。

c) fq design c)常见问题设计
Filter queries are great for their caching capabilities. 筛选器查询非常适合其缓存功能。 Here, although there are some fq that I think won't be reused so much (the is_uid filter) I suggest you to split those queries in order to have bettere reusable (ie cached) results; 在这里,尽管我认为有些qq不会被重用(is_uid过滤器),但我还是建议您拆分这些查询,以便获得更好的可重用(即缓存)结果。 something like: 就像是:

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

You are querying nothing on no fields q= . 您没有在任何字段q=上查询任何内容。 Try q=*:* , or anything on any field. 尝试q=*:*或任何字段上的任何内容。 Best way to debug solr is by constructing your query manually in the solr query builder, usually http://localhost:8983/solr and seeing what it comes back with. 调试solr的最佳方法是在solr查询构建器(通常为http:// localhost:8983 / solr)中手动构建查询,然后查看返回的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM