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

  • 相关阅读:
    外观模式
    解释器模式
    LoadRunner学习笔记(三)
    lr 中cookie的解释与用法
    LR使用web_add_cookie函数进行cookie模拟
    LoadRunner学习笔记(二)
    SVN服务器搭建和使用
    使用Jmeter监测服务器性能指标
    jmeter 使用白皮书
    intellij idea创建maven项目
  • 原文地址:https://www.cnblogs.com/a-du/p/7486603.html
Copyright © 2020-2023  润新知