0

I have a book index with fields title, description, author_name, library_id (where the book located). I want to query books that match a provided string, and I also give an array of library_ids for ranking purpose. The results with library_ids that belong to the provided list of library_ids should be ranked higher (higher score).

Is it possible to perform this type of query?

1 Answer 1

1

You can try using ids query

{
   "query": {
      "function_score": {
         "functions": [
            {
               "boost_factor": "50",
               "filter": {
                 "ids": {
                    "values": [
                       "library_ids"
                    ]
                 }
               }
            }
         ],
         "query": {
            "match_all": {}
         },
         "score_mode": "sum"
      }
   }
}

library_id must be the "_id" field.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.