开发者

How do I do a boolean OR in solr?

I am c开发者_运维问答ompletely new at this...

I am using durpal with the apachesolr module.

I have the following filter:

(  tid:19895 OR tid:19937 ) AND  type:poster"
This does not return any results, but if I have the following, it returns the results as expected
(  tid:19937 ) AND  type:poster"
EDIT: This is all in a filter. I need to have a list of tids that it could be along with having type be poster. So it has to be type:poster AND one of the following tids: 19895, 19937


although:

((tid:(19895 OR 19937)) AND type:poster) should work irrespective of defaultOperator being OR/AND

adding the clauses as separate filter is better, so add two filters as

tid:(19895 OR 19937)

type:poster

should filter out the results working as AND and also cache the results for this filter separately for improved query performance for new queries using this filter.


I think its important to note that SOLR isn't a database. Its a search engine and therefore isn't going to work like a database query you may be used to.

adding a + means the field is required

+tid:19895 would mean that TID field is required to equal exactly 19895

The * is the wildcard so adding it means your field would contain the value but not necessarily equal the value.

tid:19895* would mean TID field contains 19895

It looks like the issue is defining the field twice in the same filter???

So try removing the second "tid:"

In my testing I did this: My SOLR query is:

+type:poster

And the Filter is:

tid:19895 OR 19937

Here is another stackoverflow question similar to yours since you obviously have a different syntax than I use.

using OR and NOT in solr query


As FYI if defalut boolen clause is "OR" then give the query like this
((tid:(19895 19937)) AND type:poster) This working fine i tested

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜