I'm using the Nest.ElasticSearch library for .Net
And i have a model that i use for the index, which has a field i want to sort alphabetically (A-Z)
[Text(Fielddata = true, Analyzer = "keyword")]
public string FieldToSort { get; set; }
Then i have an endpoint i call which will make use of Nest.ElasticClient
if (sortProperty != null)
{
SortOrder sortOrder = sortValue != null && sortValue.ToLower() == "asc" ? SortOrder.Ascending : SortOrder.Descending;
switch (sortProperty.ToLower())
{
case "fieldToSort":
sortDescriptor.Field(s => s.FieldToSort , sortOrder);
break;
}
}
var response = _client.Search<FieldModel>
(
s => s.Index("indexName")
.Query(q => q
.Bool(b => b
.Filter(filterDescriptor)
.Must(sh => string.IsNullOrWhiteSpace(query) ? sh.MatchAll() : sh
.MultiMatch(mm => mm
.Fields(f => f
.Field(c => c.something, 1)
.Field(c => c.somehingelse, 3)
.Query(query)
.Operator(Operator.And)
)
)
)
)
.TrackTotalHits(true)
.MinScore(Config.ElasticSearch.MinScore)
.Sort(so => sortDescriptor)
.Skip(offset)
.Take(pageSize)
);
The problem is that when i get the list it seems to order A-Za-z, what if i want this to be case insensitive, so it doesn't take in account if it's Capital or lowercase?
question from:
https://stackoverflow.com/questions/65599938/how-to-make-a-nest-elasticsearch-case-insensitive 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…