I need Help for sort ordering most words occurrence with Query string Search

{ "title":"javascript,seo,javascript,c#,html,javascript"}
{ "title":"javascript,wordpress,seo,javascript,c#,html"}
{ "title":"javascript,wordpress,seo,c#,html,wordpress,wordpress"}
{ "title":"javascript,wordpress,seo,c#,html,javascript,wordpress"}
{ "title":"javascript,seo,seo,seo,seo,c#,html,javascript,javascript,javascript,wordpress"}
{ "title":"seo,c#,html,html,html,javascript,javascript,wordpress,wordpress"}
{ "title":"javascript,wordpress,seo,javascript,c#,html,javascript,javascript,javascript,wordpress,wordpress,wordpress,wordpress,wordpress,wordpress,wordpress,wordpress,wordpress,wordpress"}

i want sort this order

{ "title":"javascript,wordpress,seo,javascript,c#,html,javascript,javascript,javascript,wordpress,wordpress,wordpress,wordpress,wordpress,wordpress,wordpress,wordpress,wordpress,wordpress"}
{ "title":"javascript,seo,seo,seo,seo,c#,html,javascript,javascript,javascript,wordpress"}
{ "title":"javascript,wordpress,seo,c#,html,wordpress,wordpress"}
{ "title":"javascript,wordpress,seo,c#,html,javascript,wordpress"}
{ "title":"seo,c#,html,html,html,javascript,javascript,wordpress,wordpress"}
{ "title":"javascript,wordpress,seo,javascript,c#,html"}

...................................................

{
"query": {
"query_string": {
"query": "javascript and wordpress",
"default_field": "title"
}
}
}

i'm also used also
Okapi BM25. but not achive this . please sugguest this topic.

@anup786saini
You can use scripted similarity. https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-similarity.html

{
  "settings": {
    "number_of_shards": 1,
    "similarity": {
      "scripted_tfidf": {
        "type": "scripted",
        "script": {
          "source": "return query.boost * doc.freq;"
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "title": {
        "type": "text",
        "similarity": "scripted_tfidf"
      }
    }
  }
}

thank you Vinayak_Sapre for your suggest.
i use this but if some documents have same doc.freq. eg
1 doc.--->{"title":"javascript,wordpress,javascript,wordpress"} ------->4
2 doc.--->{"title":"wordpress,wordpress,javascript,wordpress"} --------->4 but
i want doc 2 on top be'coz wordpress have 3 occurence.
but. its show 1 doc top and 2 then after .
how to achive this.

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