【问题标题】:Nest and Elasticsearch - understanding the basicsNest 和 Elasticsearch - 了解基础知识
【发布时间】:2014-02-26 15:10:35
【问题描述】:

我正在学习 NEST 和弹性搜索,其中一些基础知识让我感到困惑。如果我创建一个基本索引,使用 Nest 集成测试:

var client = ElasticsearchConfiguration.Client;

        if (client.IndexExists(ElasticsearchConfiguration.DefaultIndex).Exists)
            return;

        var projects = NestTestData.Data;
        var people = NestTestData.People;

        client.CreateIndex(ElasticsearchConfiguration.DefaultIndex, c => c
            .NumberOfReplicas(0)
            .NumberOfShards(1)
            .AddMapping<ElasticSearchProject>(m => m.MapFromAttributes())
            .AddMapping<Person>(m => m.MapFromAttributes())
        );
        client.CreateIndex(ElasticsearchConfiguration.DefaultIndex + "_clone", c => c
            .NumberOfReplicas(0)
            .NumberOfShards(1)
            .AddMapping<ElasticSearchProject>(m => m.MapFromAttributes())
            .AddMapping<Person>(m => m.MapFromAttributes())
        );

        var bulkParameters = new SimpleBulkParameters() { Refresh = true };
        client.IndexMany(projects, bulkParameters);
        client.IndexMany(people, bulkParameters);
        client.Refresh(new[] {ElasticsearchConfiguration.DefaultIndex, ElasticsearchConfiguration.DefaultIndex + "_clone"});

我不了解此操作后 ElasticClient 的状态。

1) 为什么在这个操作之后 ElasticClient 仍然 Valid = False。那么Valid是什么意思呢?

2) CreateIndex 函数返回一个 IIndicesOperationResponse,它的状态属性 OK 设置为 false,即使我知道正在创建索引。 OK 是什么意思?

【问题讨论】:

标签: c# elasticsearch nest


【解决方案1】:
  1. 客户端上的 .IsValid 构造在旧版本中用作一次性 ping,以查看客户端是否可以连接到配置的主机。这早已被删除,因为它造成了更多的混乱,并没有真正提供任何东西。

  2. Elasticsearch 1.0 已标准化并从响应中删除了所有 OK 属性。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-03-30
    • 1970-01-01
    • 2011-08-11
    • 1970-01-01
    • 1970-01-01
    • 2021-04-07
    • 2011-06-14
    • 1970-01-01
    相关资源
    最近更新 更多