Problem setting text field as "not_analyzed"

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")

  			)
  		)
  	)
  )

);
}

The keyword field datatype 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. In Elasticsearch 5.2.0+ a normalizer was introduced that allows you to perform some normalization to indexed tokens e.g. lowercasing.

Thanks! That worked perfectly.

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