# Sort not works on string field

**URL:** <https://discuss.elastic.co/t/sort-not-works-on-string-field/281685>\
**Category:** Elasticsearch\
**Created:** [August 17, 2021, 1:26pm UTC](https://discuss.elastic.co/t/sort-not-works-on-string-field/281685 "2021-08-17T13:26:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahmatzadeh\_mofid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahmatzadeh_mofid/32/77570_2.png) [@rahmatzadeh\_mofid](https://discuss.elastic.co/u/rahmatzadeh_mofid)\
**Post date:** [August 17, 2021, 1:26pm UTC](https://discuss.elastic.co/t/sort-not-works-on-string-field/281685/1 "2021-08-17T13:26:45Z")

</div>

Sort() function not working on string fields of the document. this is my query:  
(I use the latest version of Nest client in c# dotnet 5)

```auto
var res = await elasticClient.SearchAsync<CustomerModel>(s => s.Index("customers").From(from)
                    .Size(filter.PageSize)
                    .Query(q => q
                        .Bool(b => b
                            .Filter(
                            sh => sh.Match(m => m.Field(f => f.PartyContracts.Any(a => a.Contract.Any(a => a.ContractTypeId == 1)))),

.Sort(q => q.Ascending(f => f.cache_FirstName))
 );

```

it doesn't give me the result but when commenting on the sort line it will be fixed.  
what is the problem?

---

<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:** [September 14, 2021, 1:27pm UTC](https://discuss.elastic.co/t/sort-not-works-on-string-field/281685/2 "2021-09-14T13:27:46Z")

</div>

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