Problem on scoring and sorting retrieved documents

Matching is a combination of a number of factors relating to your choice of analyzers and queries and the documents held inside your index. The explain API [1] can give low-level details on how things are matched.

Before you dive into this it is worth noting that the user's search text input does not have to be translated into a single choice of query clause in the elasticsearch query DSL. It often makes sense to combine multiple query expressions ranging from strict to lax in a single bool query's array of should expressions. Documents that match all of the expressions (strict and lax) will tend to rank highest. An example of a strict clause might be a query for an exact phrase match on a field analyzed with no stemming etc while an example of a sloppy clause might be the ngram approach you have here.
Thread: Synonym Problem

Cheers
Mark

[1] https://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html