# Analyzer doesn't work using nest

**URL:** <https://discuss.elastic.co/t/analyzer-doesnt-work-using-nest/79551>\
**Category:** Elasticsearch\
**Created:** [March 22, 2017, 8:24am UTC](https://discuss.elastic.co/t/analyzer-doesnt-work-using-nest/79551 "2017-03-22T08:24:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grigorios\_Loukidis](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@Grigorios\_Loukidis](https://discuss.elastic.co/u/Grigorios_Loukidis)\
**Post date:** [March 22, 2017, 8:24am UTC](https://discuss.elastic.co/t/analyzer-doesnt-work-using-nest/79551/1 "2017-03-22T08:24:08Z")

</div>

Hello! I am using elastic with nest for c#.I create analyzers on index time but on search time they don't work.

Here is my class

```
      public class Car{
      Text(Analyzer = "greek",SearchAnalyzer ="custom",Index = true,IncludeInAll = true)]
      public string SERVICE_DESC { get; set; }
      }

```

And here is my search query

```
   var response = client.Search<Nosilia>(n => n
                        .Index(index)
                        .Type(type)
                        .Size(searchSize)
                        .From(0)
                        .TrackScores(true)
                        .Query(q => q
                                     .Match(qs => qs
                                                        .Field(fieldsForSearchList[0])
                                                        .Analyzer("custom")
                                                        .Operator(Operator.And)
                                                        .Query("*"+searchWord+"*"))));

```

As I mentioned I have already created the two analyzers ("greek","custom")

---

<div class="post-metadata">

**Author:** ![Grigorios\_Loukidis](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@Grigorios\_Loukidis](https://discuss.elastic.co/u/Grigorios_Loukidis)\
**Post date:** [March 27, 2017, 10:22am UTC](https://discuss.elastic.co/t/analyzer-doesnt-work-using-nest/79551/2 "2017-03-27T10:22:55Z")

</div>

fields names must be lowercased because elastic tends to lowercase at least their first character, for example SERVICE\_DESC gets indexed as sERVICE\_DESC. So the most practical solution is to declare it as service\_desc.

---

<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:** [March 29, 2017, 6:21am UTC](https://discuss.elastic.co/t/analyzer-doesnt-work-using-nest/79551/3 "2017-03-29T06:21:45Z")

</div>

You can also [control how NEST serializes POCO property names](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/field-inference.html#camel-casing) to Elasticsearch field names with `.DefaultFieldNameInferrer(Func<string, string>)` on `ConnectionSettings`. In this particular case

```
var settings = new ConnectionSettings(new Uri("http://localhost:9200"))
    .DefaultFieldNameInferrer(s => s);

var client = new ElasticClient(settings);

```

will use the POCO property names as-is

---

<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:** [April 26, 2017, 6:21am UTC](https://discuss.elastic.co/t/analyzer-doesnt-work-using-nest/79551/4 "2017-04-26T06:21:46Z")

</div>

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