# Why does the performance difference occur when searching in the regular or keyword field?

**URL:** https://discuss.elastic.co/t/why-does-the-performance-difference-occur-when-searching-in-the-regular-or-keyword-field/333289
**Category:** Elasticsearch
**Created:** [May 12, 2023, 11:13am UTC](https://discuss.elastic.co/t/why-does-the-performance-difference-occur-when-searching-in-the-regular-or-keyword-field/333289 "2023-05-12T11:13:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Ruveyda\_Aksoy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruveyda_aksoy/32/120955_2.png) [@Ruveyda\_Aksoy](https://discuss.elastic.co/u/Ruveyda_Aksoy)
#### Post date: [May 12, 2023, 11:13am UTC](https://discuss.elastic.co/t/why-does-the-performance-difference-occur-when-searching-in-the-regular-or-keyword-field/333289/1 "2023-05-12T11:13:39Z")

</div>

Hi,

I have a question regarding query performance. The data types of the fields I am querying are as follows.

```auto
"primaryIdentificationNumber" : {
                    "type" : "keyword",
                    "fields" : {
                      "keyword" : {
                        "type" : "keyword",
                        "ignore_above" : 256
                      }
                    }
                  },
"primaryIdentificationType" : {
                    "type" : "keyword",
                    "fields" : {
                      "keyword" : {
                        "type" : "keyword",
                        "ignore_above" : 256
                      }
                    }
                  },
"emailAddress" : {
                        "type" : "keyword",
                        "fields" : {
                          "keyword" : {
                            "type" : "keyword",
                            "ignore_above" : 256
                          }
                        }
                      },
                      "emailType" : {
                        "type" : "keyword",
                        "fields" : {
                          "keyword" : {
                            "type" : "keyword",
                            "ignore_above" : 256
                          }
                        }
                      }

```

I did the questioning in two ways. The first is by taking the normal fields as below. This query took 233ms.

```auto
GET /bsts-application-*/_search?pretty
{
"query":{
	"bool":{
		"must": [{
			"nested":{
				"path": "application.applicant",
				"inner_hits":{},
				"query":{
					"bool":{
						"must":[{
							"bool":{
								"must":[{
									"match": { 
										"application.applicant.primaryIdentificationNumber": "48749018911"
									}
								},	{
									"match": {
										"application.applicant.primaryIdentificationType": "NATIONAL_ID"
									}
								}]
							}
						},	{
							"bool":{
								"must_not":[],
								"must":[{
									"nested": {
										"path": "application.applicant.email",
										"query": {
											"bool":{
												"must":[{
													"match":{
														"application.applicant.email.emailAddress": "xxx@gmail.com"
													}
												}],
												"must_not": [{
													"match": {
														"application.applicant.email.emailType": "sdf"
													}
												}]
											}
										}
									}
								}]
							}
						}]
					}
				}
			}
		}]
	}
}
}

```

I ran the second query by adding keyword to the fields like below.  
This query took 423ms.

```auto
GET /bsts-application-*/_search?pretty
{
"query":{
	"bool":{
		"must": [{
			"nested":{
				"path": "application.applicant",
				"inner_hits":{},
				"query":{
					"bool":{
						"must":[{
							"bool":{
								"must":[{
									"match": { 
										"application.applicant.primaryIdentificationNumber.keyword": "48749018911"
									}
								},	{
									"match": {
										"application.applicant.primaryIdentificationType.keyword": "NATIONAL_ID"
									}
								}]
							}
						},	{
							"bool":{
								"must_not":[],
								"must":[{
									"nested": {
										"path": "application.applicant.email",
										"query": {
											"bool":{
												"must":[{
													"match":{
														"application.applicant.email.emailAddress.keyword": "xxx@gmail.com"
													}
												}],
												"must_not": [{
													"match": {
														"application.applicant.email.emailType.keyword": "sdf"
													}
												}]
											}
										}
									}
								}]
							}
						}]
					}
				}
			}
		}]
	}
}
}

```

NOT: No caching issue.

Actually, what I want to ask is to understand the logic of the event.  
Why does it take longer when I query the keyword?

Regars,

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [June 9, 2023, 11:13am UTC](https://discuss.elastic.co/t/why-does-the-performance-difference-occur-when-searching-in-the-regular-or-keyword-field/333289/2 "2023-06-09T11:13:40Z")

</div>

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