How does elasticsearch rank matching results?


Can you explain lucidly (My knowledge in this field is almost zero) how the search engine rank matching results when a user performs a search (I think this is called search engine algorithm)? What are ranking factors? For example, the number of times that a searched string is repeated in a post is the main ranking factor? Is there any specific algorithm including such factors that the search engine use to rank matching results?

I read some documents on the official website of ElasticSearch, but I could not find the answer there.

Hi. Roughly speaking:

  • Documents matching all of your search terms are better than those that only match few.
  • Documents that repeat your search terms several times (to a limit) are better than those that mention them only once.
  • Rare terms are more interesting matches than common terms
  • Matches found in short documents are better than very long ones e.g. an encyclopedia.

Thanks for your answer. I asked this question to edit some more relevant posts so that they are appeared at the top of the search results when a given terms are searched for.

So, according to your answer, to accomplish that, the best way is adding many repetitions of the given terms in such posts?

I was describing the natural ranking that occurs if you don't do anything to influence results.

If you want to take more control there are a number of extra tools at your disposal:

Please note that I am not an administrator of the website, which is equipped with ElasticSearch, to control the tools you mentioned. I am just a regular user who can edit posts. Now, in this case, the best solution is the way I mentioned in the previous reply?


  1. You can't change the admin's query template
  2. You can't change the end user's queries
  3. There aren't already boosts e.g number of "likes' on a post
  4. You're OK with your docs containing what might look like ugly repetition

Then, "yes" that would be a way to do it

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