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

Hello All,

I am working in 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)
.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.

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