NEST: Why all my text fields in the index have keyword type?

I pushing new documents using NEST in pair with class with attributes.
Here is how I define a class:

public class PatientNestModel
    {
        [Text]
        public string FirstName { get; set; }
        [Text]
        public string LastName { get; set; }
        [Text]
        public string MiddleName { get; set; }
        [Date(Format = "dd-MM-yyyy")]
        public DateTime BirthdayDate { get; set; }
        [Keyword]
        public string Gender { get; set; }
        [Text]
        public string Phone { get; set; }
        [Nested]
        public List<AdditionalContact> AdditionalContacts { get; set; }
        [Boolean]
        public bool Active { get; set; }
    }

Here is how I pushing it:

var response = _esClient.Index(model, idx => idx.Index("patients_esindex"));

But then my index metadata looks with keyword type.

    {
    	"state": "open",
    	"settings": {
    		"index": {
    			"creation_date": "1543806292300",
    			"number_of_shards": "5",
    			"number_of_replicas": "1",
    			"uuid": "3_J5ck_CTaCLEdhIbCC0ZQ",
    			"version": {
    				"created": "6030199"
    			},
    			"provided_name": "patients_esindex"
    		}
    	},
    	"mappings": {
    		"patientnestmodel": {
    			"properties": {
    				"firstName": {
    					"type": "text",
    					"fields": {
    						"keyword": {
    							"ignore_above": 256,
    							"type": "keyword"
    						}
    					}
    				},
    				"lastName": {
    					"type": "text",
    					"fields": {
    						"keyword": {
    							"ignore_above": 256,
    							"type": "keyword"
    						}
    					}
    				},
    				"gender": {
    					"type": "text",
    					"fields": {
    						"keyword": {
    							"ignore_above": 256,
    							"type": "keyword"
    						}
    					}
    				},
    				"birthdayDate": {
    					"type": "date"
    				},
    				"phone": {
    					"type": "text",
    					"fields": {
    						"keyword": {
    							"ignore_above": 256,
    							"type": "keyword"
    						}
    					}
    				},
    				"active": {
    					"type": "boolean"
    				},
    				"middleName": {
    					"type": "text",
    					"fields": {
    						"keyword": {
    							"ignore_above": 256,
    							"type": "keyword"
    						}
    					}
    				}
    			}
    		}
    	},
    	"aliases": [],
    	"primary_terms": {
    		"0": 1,
    		"1": 1,
    		"2": 1,
    		"3": 1,
    		"4": 1
    	},
    	"in_sync_allocations": {
    		"0": [
    			"DCbu6-HvQT2ziCzhFZKU6A"
    		],
    		"1": [
    			"9SGADbBfSWuH7AanJUGgRA"
    		],
    		"2": [
    			"dPmhURTzTVWFV4z6Fh8ctw"
    		],
    		"3": [
    			"RHX67o0QQsueD6G67IXAkg"
    		],
    		"4": [
    			"aoBxi-i8Q1aVSeq1tT69Lw"
    		]
    	}
    }

But then I am able to find the needed document by text search only if I used the term with .keyword

What am I do wrong?

By default, string fields supports both full text analysis and exact keyword matches. ES will match the analyzed tokens when you are querying over field where as field.keyword will cause it to perform exact keyword match. If your use case involves only exact keyword matches, you can need to create mappings at the time of index creation.

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