Search code examples
syntaxsolrluceneedismax

Solr query behaviour


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'


Solution

  • 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))