user2572801
user2572801

Reputation: 151

Solr query which return only those docs whose all tokens are from given list

I have Solr docs in which tags field is indexed :

Doc1 -> tags:T1 T2  
Doc2 -> tags:T1 T3  
Doc3 -> tags:T1 T4
Doc4 -> tags:T1 T2 T3  

Query 1: get all docs with tags:T1 AND tags:T3 then it works and will give Doc2 and Doc4

Query 2: get all docs whose tags must be one of these [T1, T2, T3] Expected is : Doc1, Doc2, Doc4
How to model this in Solr Query?

Upvotes: 0

Views: 96

Answers (2)

ashishmohite
ashishmohite

Reputation: 1120

If i have understood your problem correctly Using field query (fq)is the right solution in this case

fq = tags:("T1", "T2","T3","T5", "T6", "T7", "T8")

Upvotes: 0

Abhijit Bashetti
Abhijit Bashetti

Reputation: 8678

check the link for more

http://www.solrtutorial.com/solr-query-syntax.html

https://wiki.apache.org/solr/SolrQuerySyntax

q=tags:(T1 OR T2 OR T3)

 tags:(T1 AND T2 AND T3)

 tags:(T1 AND T2 OR T3)

Upvotes: 1

Related Questions