本文介绍了ElasticClient.MapRaw和.CreateIndexRaw已经消失了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在更新为 0.11.5后,看起来好像 NEST .ElasticClient.MapRaw .CreateIndexRaw 方法不再受支持。他们是否被重命名或移动或完全消失?



如果它们不见了,我如何在创建索引时定义自定义分析设置?这是我试过的:

  var indexSettings = new IndexSettings()
{
NumberOfReplicas = 1,
NumberOfShards = 2,
Analysis = new AnalysisSettings()//不起作用,没有setter
{
//这里是我的设置将...
}
};

var response = elasticClient.CreateIndex(indexName,indexSettings);

由于没有为IndexSettings.Analysis定义设置器,因此不起作用。

解决方案

原始调用被推送到 elasticClient.Raw.CreateIndexPost(...)



对于0.11.5.0版本,我创建了自己的脚本,扫描弹性搜索源代码以生成所有原始调用。显然,弹性搜索开发人员也做到了这一点,所以在0.11.6.0版本中, IRawElasticClient 签名可能会再次发生变化,因为NEST将与新的低级客户端指南兼容。 >

另外,请务必查看 MapFluent()通话





CreateIndex()还暴露了一个完全映射的流利变体




After updating to NEST 0.11.5, it appears as if the NEST.ElasticClient.MapRaw and .CreateIndexRaw methods aren't supported anymore. Have they been renamed or moved or are they completely gone?

In case they're gone, how can I define custom analysis settings on index creation? This is what I've tried:

var indexSettings = new IndexSettings()
    {
        NumberOfReplicas = 1,
        NumberOfShards = 2,
        Analysis = new AnalysisSettings()  // doesn't work, no setter
            {
                // here's where my settings would go...
            }
    };

var response = elasticClient.CreateIndex(indexName, indexSettings);

Doesn't work since there's no setter defined for IndexSettings.Analysis.

解决方案

The Raw calls have been pushed down to elasticClient.Raw.CreateIndexPost(...).

For the 0.11.5.0 release i created my own script that scans the elasticsearch source code to generate all the raw calls. Appearantly the elasticsearch dev's have also done this so the IRawElasticClient signatures might changes again in the 0.11.6.0 release as NEST will be compatible with the new low level client guidelines.

Also be sure to check out the MapFluent() call though

https://github.com/Mpdreamz/NEST/blob/master/src/Nest.Tests.Unit/Core/Map/FluentMappingFullExampleTests.cs

And CreateIndex() also exposes a fully mapped fluent variant

https://github.com/Mpdreamz/NEST/blob/master/src/Nest.Tests.Integration/Indices/Analysis/Analyzers/AnalyzerTests.cs#L19

这篇关于ElasticClient.MapRaw和.CreateIndexRaw已经消失了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 05:07