开发者

SOLR - how to do a fuzzy search on booleans

开发者 https://www.devze.com 2023-01-06 23:46 出处:网络
If my index contains three boolean fields: a, b and c... I would like to search for: \"a=True, 开发者_如何学Gob=False, c=True\" and SOLR should return all entries, and their score should represent how

If my index contains three boolean fields: a, b and c...

I would like to search for: "a=True, 开发者_如何学Gob=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 ?


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消