博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Create Index using NEST .NET
阅读量:4677 次
发布时间:2019-06-09

本文共 5058 字,大约阅读时间需要 16 分钟。

Hello Guys,

I have a doubt about how create index using NEST .NET. I created every fields in my C# method, however when i'll see the json created in elasticsearch the _all field doesn't exists. Follow below the method, it's created the type in elasticsearch and the json got on elasticsearch. May someone help me, please?

C# Method(Partial Fields)

private void CreateMappings()
{
_client.Map(descriptor =>
{
descriptor.Index(DefaultIndexName);

descriptor.Properties(propertiesDescriptor =>		{			propertiesDescriptor.Number(prod => prod.Name(produto => produto.id).Index(true).Type(NumberType.Long).IncludeInAll(true));			propertiesDescriptor.Number(prod => prod.Name(produto => produto.id_Migracao).Index(true).Type(NumberType.Short).IncludeInAll(false));			propertiesDescriptor.Number(prod => prod.Name(produto => produto.id_Loja).Index(true).Type(NumberType.Short).IncludeInAll(false));			propertiesDescriptor.Text(prod => prod.Name(produto => produto.ds_Produto).IncludeInAll(true).Analyzer("brazilian").Fields(mf => mf.Text(vl => vl.Name(f => f.ds_Produto.Suffix("original")).IncludeInAll(false).Index(false))));			propertiesDescriptor.Text(prod => prod.Name(produto => produto.cd_Produto).Index(true).IncludeInAll(true).Analyzer("brazilian"));			propertiesDescriptor.Number(prod => prod.Name(produto => produto.id_Fabricante).Index(true).Type(NumberType.Integer).IncludeInAll(false));			propertiesDescriptor.Text(prod => prod.Name(produto => produto.ds_Fabricante).Index(true).IncludeInAll(true).Analyzer("brazilian").Fields(mf => mf.Text(vl => vl.Name(f => f.ds_Produto.Suffix("original")).IncludeInAll(false).Index(false))));			propertiesDescriptor.Number(prod => prod.Name(produto => produto.vr_Avaliacao).Index(true).Type(NumberType.Short).IncludeInAll(false));			propertiesDescriptor.Boolean(prod => prod.Name(produto => produto.is_Disponivel).Index(true));			propertiesDescriptor.Boolean(prod => prod.Name(produto => produto.is_Oferta).Index(true));			propertiesDescriptor.Boolean(prod => prod.Name(produto => produto.is_ExibirSempre).Index(true));			propertiesDescriptor.Number(prod => prod.Name(produto => produto.qt_Disponivel).Index(true).Type(NumberType.Integer).IncludeInAll(false));			propertiesDescriptor.Number(prod => prod.Name(produto => produto.qt_Vendido).Index(true).Type(NumberType.Integer).IncludeInAll(false));			propertiesDescriptor.Number(prod => prod.Name(produto => produto.id_Promocao).Index(true).Type(NumberType.Long).IncludeInAll(false));			propertiesDescriptor.Number(prod => prod.Name(produto => produto.vr_PrecoPor).Index(true).Type(NumberType.Double).IncludeInAll(false));			propertiesDescriptor.Number(prod => prod.Name(produto => produto.vr_PrecoDe).Index(true).Type(NumberType.Double).IncludeInAll(false));			propertiesDescriptor.Number(prod => prod.Name(produto => produto.qt_Parcelas).Index(true).Type(NumberType.Short).IncludeInAll(false));			propertiesDescriptor.Number(prod => prod.Name(produto => produto.vr_Parcelas).Index(true).Type(NumberType.Double).IncludeInAll(false));			propertiesDescriptor.Number(prod => prod.Name(produto => produto.qt_ParcelasSemJuros).Index(true).Type(NumberType.Short).IncludeInAll(false));			propertiesDescriptor.Number(prod => prod.Name(produto => produto.vr_ParcelasSemJuros).Index(true).Type(NumberType.Double).IncludeInAll(false));			propertiesDescriptor.Number(prod => prod.Name(produto => produto.vr_TaxaJuros).Index(true).Type(NumberType.Double).IncludeInAll(false));			propertiesDescriptor.Text(prod => prod.Name(produto => produto.ds_hierarquia_categoria).Index(false).IncludeInAll(false));			propertiesDescriptor.Boolean(prod => prod.Name(produto => produto.is_FotoRotativa).Index(true));			propertiesDescriptor.Number(prod => prod.Name(produto => produto.qtd_rotativa).Index(true).Type(NumberType.Integer).IncludeInAll(false));			propertiesDescriptor.Boolean(prod => prod.Name(produto => produto.is_Disponibilidade).Index(true));			propertiesDescriptor.Text(prod => prod.Name(produto => produto.guid_transacao).Index(true).IncludeInAll(false).Analyzer("brazilian"));						return propertiesDescriptor;		});		return descriptor;	});}

JSON(Partial fields)

{
"fernando_v02": {
"mappings": {
"produtos": {
"properties": {
"cd_Produto": {
"type": "text",
"analyzer": "brazilian",
"include_in_all": true
},
"ds_Fabricante": {
"type": "text",
"fields": {
"original": {
"type": "text",
"index": false,
"include_in_all": false
}
},
"analyzer": "brazilian",
"include_in_all": true
},
"ds_Produto": {
"type": "text",
"fields": {
"original": {
"type": "text",
"index": false,
"include_in_all": false
}
},
"analyzer": "brazilian",
"include_in_all": true
},
"ds_UrlImagem": {
"type": "text",
"index": false,
"include_in_all": false
},
"ds_hierarquia_categoria": {
"type": "text",
"index": false,
"include_in_all": false
},
"dt_Lancamento": {
"type": "date",
"include_in_all": false
},
"guid_transacao": {
"type": "text",
"analyzer": "brazilian",
"include_in_all": false
},
"id": {
"type": "long",
"include_in_all": true
},....
....
}
}

转载于:https://www.cnblogs.com/a-du/p/7486603.html

你可能感兴趣的文章
使用iframe实现同域跨站提交数据
查看>>
Mouse点击之后,复制GridView控件的数据行
查看>>
ASP.NET开发,从二层至三层,至面向对象 (2)
查看>>
如何查看自己电脑支持OpenGL core版本
查看>>
页面元素定位 XPath 简介
查看>>
[转]loadrunner:系统的平均并发用户数和并发数峰值如何估算
查看>>
Linux下Tomcat重新启动
查看>>
HTML Table to Json
查看>>
Theano 学习笔记(一)
查看>>
1.7 节点进行排序显示
查看>>
web最佳实践
查看>>
spring 集成shiro 之 自定义过滤器
查看>>
验证密码不允许有连续三位重复的正则表达式
查看>>
python 中对list去重
查看>>
Mono Libgdiplus库
查看>>
js模糊查询案例
查看>>
c语言基础知识要点
查看>>
Android模拟器无法上网访问网络失败解决办法
查看>>
node启动时, listen EADDRINUSE 报错;
查看>>
vue学习链接
查看>>