I have a Solr installation that contains recipes.
Each recipe has multiple ingredients and I'm currently building a recipe search that you can type 'includes/excludes' and then I have a homebrew weight system that comes in after this.
The query building is off however and so needs refining.
// Works perfect - 109 results
ingredients:chicken OR tomatoes OR bacon
// Down to 7 results - Definitely wrong
ingredients:chicken OR tomatoes OR bacon AND -ingredients:garlic
I've tried building this query any which way but can't figure out an acceptable 'fuzzy filter'
I would do:
ingredients:((chicken OR tomatoes OR bacon) AND NOT garlic)
This works for me.
You can add all excludes like this:
ingredients:((chicken OR tomatoes OR bacon) AND NOT (garlic OR peanuts OR spinach))
Try ingredients:chicken OR tomatoes OR bacon AND (-ingredients:garlic)
I am assuming that you are you are using Solr 3.1 with edismax
.
I have found that enclosing negative queries in parenthesis works. I have not had the time to look into this in more detail and figure out if this is the expected behaviour or is it a bug. If you investigate this in more detail and confirm that this is a bug, then please open a Jira issue here .
Note that the query I suggested above will search for tomatoes / bacon in the default field(s) as per your config. If you want to search for them in ingredients
only, then use ingredients:(chicken OR tomatoes OR bacon) AND (-ingredients:garlic)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.