Jens Kraemer wrote: > have a look at ConstantScoreQuery. It allows to turn a Filter into a > query where all results score equally. > > To get this Filter, you could use the QueryFilter class, which allows > you to turn your original query into a Filter. > > query = > ConstantScoreQuery.new(QueryFilter.new(TermQuery.new(:ingredients, > 'beef')) > > looks like there should be an easier way to achieve this, though ;-) > > Jens
Jens, Thanks a lot for help. The ConstantScoreQuery with QueryFilter and TermQuery/MultiTermQuery work fine. I am able to get constant value for all of the ingredients inserted into the query. The problem appears when I would like to get more precise results with multiple ingredients inserted. So, coming back to my example: recipe1: "beef" recipe2: "onion beef chicken" recipe3: "onion beef chicken tomato" recipe4: "onion chicken" All results from that query are equal and that's great: query = ConstantScoreQuery.new(QueryFilter.new(TermQuery.new(:ingredients, 'beef')) When I put more than one ingredient into account I would like to distinguish different scores for recipes which: include three of them, include two of them, recipes which has one of them only. So I would like create a query which return 100% hits for recipe2 and recipe3, appropriately less for recipe4 and adequately less for recipe1. I created multi query like that: multi_term_query = MultiTermQuery.new(:ingredients) multi_term_query << "onion" << "beef" << "chicken" query = ConstantScoreQuery.new(QueryFilter.new(multi_term_query) but it doesn't work at all. Any ideas? Thanks in advance, mlynco -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ferret-talk mailing list [email protected] http://rubyforge.org/mailman/listinfo/ferret-talk

