Score results based in a list of ids


(Augusto César Ribeiro) #1

Hello guys!
This is my first time using ElasticSearch so I'm sorry if I missed any documentation.
So I'm trying to setup a query that will prioritize the document's whose id is in a .txt file that I have. What is the best aproach to do that? Should I upload these ids to a different index and compare them?

Here's what I have so far:

GET users/_search
{
  "query": {
    "function_score": {
      "query": { "match_all": {} },
      "boost": "5",
      "functions": [
        {
          "filter": {
            "terms" :{
              "_id": [
                id1,
                id2,
                id3,
                ...
              ]
            }
          },
          "weight": 2
        }
      ],
      "boost_mode":"multiply"
    }
  }
}

Thanks in advance!


(Mayya Sharipova) #2

Should I upload these ids to a different index and compare them?

There is no way in elasticsearch to do queries across multiple indexes. You best choice is to list ids the way you are doing it.


(system) #3

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