Elastic Nest accessing sub property of text

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.

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

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

You can use .Suffix("words_count")

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