How can I exclude a set of document IDs from Solr result set? Essentially something like
/select?q=tag_id:367 AND NOT id:(306670,302209)
I tried it and it does not exclude documents with those id's.
Solr queries require escaping special characters that are part of the query syntax. Special characters are: +, -, &&, ||, !, (, ), ", ~, *, ?, and : . To escape these characters, use a slash ( \ ) before the character to escape.
Trying a basic queryThe main query for a solr search is specified via the q parameter. Standard Solr query syntax is the default (registered as the “lucene” query parser). If this is new to you, please check out the Solr Tutorial. Adding debug=query to your request will allow you to see how Solr is parsing your query.
The df stands for default field , while the qf stands for query fields . The field defined by the df parameter is used when no fields are mentioned in the query. For example if you are running a query like q=solr and you have df=title the query itself will actually be title:solr .
Try this:
/select?q=*:*&fq=tag_id:367 AND id:[* TO *] -id:(306670 302209)
That should allow you to build out add as many ids as you want without having to add -id:302209
every time you want to eliminate an ID. The reverse is also true, you can swap the -
with a +
and force an array of values to be there as well.
Found one solution:
/select?q=tag_id:367&fq=-id:306670 AND -id:302209
Not sure whether this is the best way to do it though!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With