zoukankan      html  css  js  c++  java
  • Create Index using NEST .NET

    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
    },....
    ....
    }
    }

  • 相关阅读:
    MySQL 子查询
    MySQL 多表查询 内连接 和 外连接
    MySQL 分页
    MySQL 常用函数 流程控制
    Envoy基于文件系统的EDS动态配置
    Envoy学习笔记
    dapr入门学习
    浅谈cache
    List的初始化方式
    屌丝公司:设置服务器的时区、时间及时间同步
  • 原文地址:https://www.cnblogs.com/a-du/p/7486603.html
Copyright © 2011-2022 走看看