# Facing query, sorting related issues on string/text type fields

**URL:** <https://discuss.elastic.co/t/facing-query-sorting-related-issues-on-string-text-type-fields/121644>\
**Category:** Elasticsearch\
**Created:** [February 27, 2018, 11:43am UTC](https://discuss.elastic.co/t/facing-query-sorting-related-issues-on-string-text-type-fields/121644 "2018-02-27T11:43:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nmathur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nmathur/32/21451_2.png) [@nmathur](https://discuss.elastic.co/u/nmathur)\
**Post date:** [February 27, 2018, 11:43am UTC](https://discuss.elastic.co/t/facing-query-sorting-related-issues-on-string-text-type-fields/121644/1 "2018-02-27T11:43:14Z")

</div>

Hello All,

I am working in [ASP.NET](http://ASP.NET) MVC5 C# using Nest library.

I have some important columns with text/string type and have to apply in clause/query on it and also need to apply sort based on them.

I am using below terms query and it is returning 0 results:

> var searchResponse = ElasticClientContext.Search(s =\> s\> .From(0)  
> .Size(ESClient.PageSize).Index("myindex").Type("employee")  
> .Query(q =\> q.Terms(t =\> t.Field(f =\> f.DepartmentName).Terms(deptNames))));  
> return searchResponse.Documents.ToList();

Sorting is returning below message:  
**_Fielddata is disabled on text fields by default. Set fielddata=true on [depatrmentName] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead._**

Please help. .. are both issues related .. do I need to set fielddata=true to apply terms query on this column .. why text type fields are not mapped and how to set fielddata=true at the time of index creation or put mapping.

Thanks in advance.

---

<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:** [March 27, 2018, 11:43am UTC](https://discuss.elastic.co/t/facing-query-sorting-related-issues-on-string-text-type-fields/121644/2 "2018-03-27T11:43:24Z")

</div>

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