# Elastic Nest accessing sub property of text

**URL:** <https://discuss.elastic.co/t/elastic-nest-accessing-sub-property-of-text/160887>\
**Category:** Elasticsearch\
**Created:** [December 14, 2018, 10:58am UTC](https://discuss.elastic.co/t/elastic-nest-accessing-sub-property-of-text/160887 "2018-12-14T10:58:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amol\_Hegana](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@Amol\_Hegana](https://discuss.elastic.co/u/Amol_Hegana)\
**Post date:** [December 14, 2018, 10:58am UTC](https://discuss.elastic.co/t/elastic-nest-accessing-sub-property-of-text/160887/1 "2018-12-14T10:58:48Z")

</div>

I have created text property **name** also i have created sub property as **words\_count of name** and i want to have range query on words\_count of name. How can i access it in c# using Nest.

```auto
"mappings": {
"person": {
  "properties": {
    "name": { 
      "type": "text",
      "fields": {
        "keyword": { 
          "type": "keyword"
        },
        "words_count": { 
          "type": "token_count",
          "analyzer": "standard"
        },
        "length": { 
          "type": "token_count",
          "analyzer": "character_analyzer"
        }
      }
    }
  }
}
}

```

I have length of name but its from c# string length. I want access words\_count sub property of name created in elastic.

```auto
c# code

Func<QueryContainerDescriptor<MyType>, QueryContainer> query = m => m
                                    .Range(r => r.Field(f => f.name.words_count).Relation(RangeRelation.Within)
                                    .GreaterThanOrEquals(10).LessThanOrEquals(14));

```

---

<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:** [December 14, 2018, 12:08pm UTC](https://discuss.elastic.co/t/elastic-nest-accessing-sub-property-of-text/160887/2 "2018-12-14T12:08:34Z")

</div>

You can use [`.Suffix("words_count")`](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/field-inference.html#_complex_field_name_expressions)

---

<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:** [January 11, 2019, 12:08pm UTC](https://discuss.elastic.co/t/elastic-nest-accessing-sub-property-of-text/160887/3 "2019-01-11T12:08:43Z")

</div>

Closed on January 11, 2019, 12:08pm UTC

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