问题
I used to use the add-sort-field=true as an attribute to a property, but with the new nest I can't find the equivalent. Where is it?
Thanks.
回答1:
Looks like it has been accidently removed from NEST 2.x. I couldn't find any trace why. Feel free to ask this question if you think it was useful in your case. Link to the NEST github.
As far I as I understand, property was creating fieldname.sort field which was not_analyzed.
For time being you can handle this by explicit creating field. Unfortunately you won't be able to do this with attribute-based mapping, but you can successfully mix two techniques.
var createIndexResponse = client.CreateIndex(indexName, descriptor => descriptor
.Mappings(map => map
.Map<Document>(m => m
.AutoMap()
.Properties(ps => ps
.String(s => s
.Name(n => n.Country)
.Fields(f => f
.String(ss => ss.Name(n => n.Country.Suffix("sort")).NotAnalyzed()))))
)));
public class Document
{
public int Id { get; set; }
[String(Name = "c")]
public string Country { get; set; }
}
Hope it helps you.
来源:https://stackoverflow.com/questions/36425486/addsortfield-in-nest-2-upgrade