Multiple Dependent Signals Function Score Query

(Sandeep Tammu) #1


I would like to do a non-trivial function_score query for the domain in which I am working on. Let me try to explain you what I'm trying to achieve.

Let's say you have an inventory of Apples. Each day, you get a new record about the amount of apples that are currently in the inventory. The objective of the query is to give a score to each document based on how many apples are there in the inventory for that particular document, and how recently the inventory has been updated. What I ended up doing was to put this list of dictionaries into a nested document so that I can query each child independently.

So my document structure is:

"nested_field" : [{"item_name": "apple", "quantity" : 10, "updated_time" : 23434},
"item_name": "apple", "quantity" : 24, "updated_time" : 23439}]

My scoring function requires two things.

  1. Total quantity of Apples
  2. Last updated time

But, it's not a linear independent combination of those two parameters. It requires one to calculate the other. If I have more apples than a competitor and my inventory is the most recently updated one, I get a boost. Otherwise, I get a penalty. I tried to decouple my scoring function, but if I decouple, it wouldn't be able to what I wanted to do accurately.

How do I accomplish this in "function_score" query?

This is closely related to what is mentioned in this issue.



(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.