elasticsearchpyelasticsearch

Elastic Search boost query corresponding to first search term


I am using PyElasticsearch (elasticsearch python client library). I am searching strings like Arvind Kejriwal India Today Economic Times and that gives me reasonable results. I was hoping I could increase weight of the first words more in the search query. How can I do that?

res = es.search(index="article-index", fields="url", body={
  "query": {
    "query_string": {
      "query": "keywordstr",
      "fields": [
        "text",
        "title",
        "tags",
        "domain"
      ]
    }
  }
})

I am using the above command to search right now.


Solution

  • Lucene Query Syntax does the trick. Thanks

    http://lucene.apache.org/core/2_9_4/queryparsersyntax.html#Boosting%20a%20Term