我在我的 .NET 项目中使用 NEST 2.3.1。
我对它很陌生。
正如我在一个教程中看到的那样,我已经完成了这段代码。
using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Xml.Linq;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nest;
using Newtonsoft.Json;
using System.Data.Entity;
namespace Elastic_ConsoleApp
{
class Program
{
public static Uri node;
public static ConnectionSettings settings;
public static ElasticClient client;
static void Main(string[] args)
{
node = new Uri("http://localhost:9200");
settings = new ConnectionSettings(node);
client = new ElasticClient(settings);
settings.DefaultIndex("my_blog");
var indexSettings = new IndexSettings();
indexSettings.NumberOfReplicas = 1;
indexSettings.NumberOfShards = 1;
client.CreateIndex(c => c
.Index("my_blog")
.InitializeUsing(indexSettings)
.AddMapping<Post>(m => m.MapFromAttributes()));
}
}
}
但它不起作用,我收到此错误:
Error CS1660 Cannot convert lambda expression to type 'IndexName' because it is not a delegate type
在线:
client.CreateIndex(c => c
.Index("my_blog")
.InitializeUsing(indexSettings)
.AddMapping<Post>(m => m.MapFromAttributes()));
我已经尝试在 Google 上搜索,但我只得到旧版本的帮助!
提前致谢。
最佳答案
您正在使用新的 ElasticSearch Nest 尝试旧方法。 您的代码将适用于 NEST Ver。 1.X. 更新您的代码以获得新版本,或者您可以使用旧版本的 NEST。
关于c# - NEST 2.3.1 (Elastic Search) 创建索引出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37405665/