views:

112

answers:

1

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 ?

+1  A: 

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)

Mauricio Scheffer
Option 1 would be great, but unfortunately I have over 90 of these boolean fields...But option 2 seems to be a real good choice (I'm using sqedist, which doesn't take the square root and should suffice, because I'm only using 1's and 0's)...
Jann