Elasticsearch Combine Term and Match Phrase Query And Performance Issue

In the below, I shared a Elastic Search raw query. I used ElasticSearch 6.X verison.

In the given ElasticSearch Raw query that is above, I try to generate a result like this t-sql command in below.

Here is T-Sql Command

Select * from where Departman=”IT” and CountryCoude=”US” and employeeName Like’Ey%’ and employeeSurname like’Ars%’ and birthdate>=’1991-01-01’

Here is the Raw Query For ElasticSearch

Note:Departman and Country field marked as [keyword] to get exact
matching.

   {
  "size": 3,
  "query": {
    "bool": {
      "must": [
        {
          "match_phrase_prefix": {
            "employeeName": {
              "query": "Ey"
            }
          }
        },
        {
          "match_phrase_prefix": {
            "emplotyeSurname": {
              "query": "Ars"
            }
          }
        },
        {
          "range": {
            "birthday": {
              "gte": "1991-01-01T00:00:00"
            }
          }
        }
      ],
      "filter": [
        {
          "terms": {
            "Departman": [
              "IT"
            ]
          }
        },
        {
          "terms": {
            "CountyryCode": [
              "US"
            ]
          }
        }
      ]
    }
  }
}

I have a few question about this Elastic Search Query.

Firstly, I try to combine term and match query. Am I correct or do you have any advice for me?

At there I used filter keyword in departman and country . My aim is that use caching ability of ElasticSearch for filters via department and countryCode field. Is there Am I correct?

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