Max
Max

Reputation: 9879

NEST encoding issue?

Using NEST+ElasticSearch, I suspect that characters which require special encoding aren't handled properly. Example: this doesn't return any results

var results = 
client.Search<MyClass>(s => s.Query(q => q.Term(t => t.ProgrammingLanguage, "C#")));

but works fine after replacing "C#" with, for example, "Ruby". Looking at the index, there should be results for both searches.

Known issue? Is there a workaround?

Upvotes: 1

Views: 478

Answers (1)

Martijn Laarman
Martijn Laarman

Reputation: 13536

This is not an encoding issue but more or less how lucene and by proxy elasticsearch works.

The default analyzer will split words and so C# will become just 'c'. Look into elasticsearch analyzers so that your field data is stored as is using something like the keyword analyzer.

see http://www.elasticsearch.org/guide/reference/index-modules/analysis/ for more info

Upvotes: 2

Related Questions