How can we alter the score field for specific documents depending on a particular condition

Hi there,

I am working on a current scenario where there is a need to boost few documents in case of there is a particular text search.
The scenario is, I have a set of documents where I have to do the term query based on a particular keyword , but the catch here is. Let's say we search for a keyword test it will fetch 100 records but the requirement says that few docs should come as top result, irrespective of there weightage and other criteria. How can we achieve this is Elasticsearch, any suggestion and ideas are most welcome.

Have a look at function_score. The simplest thing is to add a big score to the docs that you want at the top. You might want to squash the scores of all documents that don't match the query as well to make sure they don't get to the top.