Hi,
I have a question regarding query performance. What is the difference between querying the normal field and querying the keyword field? I did a test. The data types of the fields I am querying are as follows.
"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 ran my first query with normal fields like below. This query took 233ms.
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 my second query with keyword fields like below. This query took 423ms.
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"
}
}]
}
}
}
}]
}
}]
}
}
}
}]
}
}
}
Actually, what I want to do is to understand the logic of the event.
Why did the query take longer when I used the keyword field in the query? What is the working logic?
Regars