Tire: Document boost / "Not in" syntax

2 questions:

  1. With Sunspot I could have a boost command and add score to a document
    based on a calculation

searchable do
...
boost { popularity * 0.1 }
end

this would boost an instance based on a numeric fields named popularity.

How do I implement it with Tire?

  1. How do I exclude results that match one value of a list? Let's say I
    want to exclude all documents with a field id is 1 or 2 or 3. (Like SQL's
    WHERE id NOT IN (1,2,3))

--

Ad 1/, you can use a custom_score_query, providing it a script.
See https://github.com/karmi/tire/blob/master/test/integration/custom_score_queries_test.rb#L29-45
for example code.

Ad 2/, it depends a bit on context, but you can either use a bool query
[Elasticsearch Platform — Find real-time answers at scale | Elastic]
with a must_not clause, or a filtered query with a not filter
[Elasticsearch Platform — Find real-time answers at scale | Elastic,
Elasticsearch Platform — Find real-time answers at scale | Elastic]

Karel

On Friday, October 26, 2012 2:05:29 AM UTC+2, Elad Ossadon wrote:

2 questions:

  1. With Sunspot I could have a boost command and add score to a document
    based on a calculation

searchable do
...
boost { popularity * 0.1 }
end

this would boost an instance based on a numeric fields named popularity.

How do I implement it with Tire?

  1. How do I exclude results that match one value of a list? Let's say I
    want to exclude all documents with a field id is 1 or 2 or 3. (Like SQL's
    WHERE id NOT IN (1,2,3))

--