Nest 2升级中的AddSortField [英] AddSortField in nest 2 upgrade
问题描述
我曾经将add-sort-field = true用作属性的属性,但是有了新的嵌套,我找不到等效的属性.在哪里?
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?
谢谢.
推荐答案
好像已被意外地从NEST 2.x中删除了.我找不到原因的踪影.如果您认为这对您的情况有用,请随时提出此问题. 链接到NEST github .
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.
据我了解,属性正在创建fieldname.sort
字段,该字段为not_analyzed
.
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; }
}
希望它对您有帮助.
这篇关于Nest 2升级中的AddSortField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!