# Problem setting text field as "not\_analyzed"

**URL:** <https://discuss.elastic.co/t/problem-setting-text-field-as-not-analyzed/90763>\
**Category:** Elasticsearch\
**Created:** [June 25, 2017, 6:14pm UTC](https://discuss.elastic.co/t/problem-setting-text-field-as-not-analyzed/90763 "2017-06-25T18:14:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Zalen](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@Matt\_Zalen](https://discuss.elastic.co/u/Matt_Zalen)\
**Post date:** [June 25, 2017, 6:14pm UTC](https://discuss.elastic.co/t/problem-setting-text-field-as-not-analyzed/90763/1 "2017-06-25T18:14:03Z")

</div>

Hi all,

I'm using the latest NEST c# driver with the latest Elasticsearch (5.x), and I'm having the hardest time setting a text field of one of my documents to "not\_analyzed" using fluent mapping.

Below is my latest attempt. I've tried dozens of variations of that. For simplicity's sake, let's assume that my object is of Type LoanDetail, and there is only one field on that object. It's a string, with the field name, "Purpose."

Any advice would be much appreciated. Here's my code:

> var settings = new ConnectionSettings(node).DefaultIndex("loandetails");  
> var client = new ElasticClient(settings);

> //create the index if it doesn't exist  
> if (!client.IndexExists("loandetails").Exists)  
> {

> var response = client.CreateIndex("loandetails", l =\> l  
> .Mappings(ms =\> ms  
> .Map(m =\> m  
> .Properties(ps =\> ps  
> .Text(t =\> t  
> .Name(pn =\> pn.Purpose)  
> .Analyzer("not\_analyzed")

> ```
> )
> )
> )
> )
> 
> ```
> 
> );  
> }

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [June 25, 2017, 11:44pm UTC](https://discuss.elastic.co/t/problem-setting-text-field-as-not-analyzed/90763/2 "2017-06-25T23:44:59Z")

</div>

The [**keyword** field datatype](https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html) is what you are after here, which will index the string verbatim:

```
var response = client.CreateIndex("loandetails", l => l
	.Mappings(ms => ms
		.Map<LoanDetail>(m => m
			.Properties(ps => ps
				.Keyword(t => t
					.Name(pn => pn.Purpose)
				)
			)
		)
	)
);

```

[String datatypes were split into keyword and text in 5,0](https://www.elastic.co/blog/strings-are-dead-long-live-strings). In Elasticsearch 5.2.0+ a [`normalizer` was introduced](https://www.elastic.co/guide/en/elasticsearch/reference/5.2/normalizer.html#normalizer) that allows you to perform some normalization to indexed tokens e.g. lowercasing.

---

<div class="post-metadata">

**Author:** ![Matt\_Zalen](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@Matt\_Zalen](https://discuss.elastic.co/u/Matt_Zalen)\
**Post date:** [June 26, 2017, 5:12am UTC](https://discuss.elastic.co/t/problem-setting-text-field-as-not-analyzed/90763/3 "2017-06-26T05:12:07Z")

</div>

Thanks! That worked perfectly.

---

<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:** [July 24, 2017, 5:12am UTC](https://discuss.elastic.co/t/problem-setting-text-field-as-not-analyzed/90763/4 "2017-07-24T05:12:08Z")

</div>

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