Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In the edit search page form, we have the following explanatory text:
'A comma-separated list of lucene filter queries to apply by default. E.g. "bundle:blog, is_uid:(1 OR 2 OR %). % will be replaced by the value of % in the path"'
I couldn't find any documentation anywhere about how to exclude terms, and eventually managed to deduce it from the source code. But perhaps it should explain that "-bundle:blog" with a minus sign in front of it will exclude all blog items.
Comments
Comment #1
Nick_vhI'd be happy to commit a better documentation in regards to this fact. Could you make a start and/or a patch?
Comment #2
cpliakas CreditAttribution: cpliakas commentedDo you think it would make sense to add a link to the Apache Lucene - Query Parser Syntax page or copy the text into a help page? In addition, it might help to point people to the Reports page so they can see what fields are available.
Comment #3
arebacollins CreditAttribution: arebacollins commentedI still dont get how this works: How do I exclude all content of type plant_pests where field is_minor_pest is 1 (meaning I would like to include plant_pests where field is_minor_pest is 0 in the search)?
Thanks.
Comment #4
jgrubb CreditAttribution: jgrubb as a volunteer commented@arebacollins something like this --
bundle:"plant_pests" AND is_minor_pest:0
Comment #5
ThePickwickProject CreditAttribution: ThePickwickProject commented@arebacollins
I was running in a similar problem and I was able to solve it when I realized you need to use the field names as known and indexed by Lucene / Solr.
e.g. when you want to filter on the content type field is_minor_pest, you'll likely have a field "sm_is_minor_pest" and the syntax would be sm_is_minor_pest:0 You can find these field names when using facets.
If someone has more additional info, specifically about how to create an Apache Solr Search Page that restricts search to all content from a content type where a field has a specific value, I would be interested.
e.g. Content Type: News with field_news_type: Sports
the syntax to use is probably not
bundle:"News" AND field_news_type:"Sports"
but rather something like
bundle:"Newss" AND sm_field_news_type:"Sports"