【发布时间】:2016-09-21 04:48:19
【问题描述】:
我在我的 .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()));
}
}
}
但它不起作用,我收到此错误:
错误 CS1660 无法将 lambda 表达式转换为类型“IndexName”,因为它不是委托类型
在线:
client.CreateIndex(c => c
.Index("my_blog")
.InitializeUsing(indexSettings)
.AddMapping<Post>(m => m.MapFromAttributes()));
我已尝试在 Google 上搜索,但我只获得旧版本的帮助!
提前致谢。
【问题讨论】:
-
这看起来像 NEST 1.x API,与 NEST 2.x 略有不同。您可以在弹性站点上找到 NEST 2.x 的文档:elastic.co/guide/en/elasticsearch/client/net-api/2.x/index.html
-
是的!太感谢了! @RussCam
标签: c# elasticsearch indexing delegates nest