Search code examples
solrlucenefuzzy-search

SOLR - how to do a fuzzy search on booleans


If my index contains three boolean fields: a, b and c...
I would like to search for: "a=True, b=False, c=True" and SOLR should return all entries, and their score should represent how good the whole query is matched.

e.g.

a=T, b=F, c=T, score=1.0  
a=T, b=T, c=T, score=0.6  
a=T, b=T, c=F, score=0.5  

is that possible ?


Solution

  • Assuming true=1, false=0, a couple of ideas:

    • Build every combination with its corresponding boost in the client, e.g.:

      (a:1 AND b:0 AND c:1) OR (a:1 OR b:1 OR c:1)^0.6 OR...
      
    • Use the dist function query, e.g.: dist(1, a,b,c, 1,0,1) (requires Solr 1.5+) (I haven't used this, you might have to multiply this by -1)