Elasticsearch和.NET [英] Elasticsearch and .NET

查看:159
本文介绍了Elasticsearch和.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在考虑从Solr的/ Solr.net切换到Elasticsearch。我们开始与 NEST 。我们只有4在搜索索引文件。

We're considering to switch from Solr/Solr.net to Elasticsearch. We started with NEST. We have only 4 documents in search index.

private static void Main(string[] args)
{
    var node = new Uri("http://localhost:9200");
    var settings = new ConnectionSettings(
        node, "my-application");

    var client = new ElasticClient(settings);

    var stopwatch = Stopwatch.StartNew();
    var sr = client.Get<Movie>(1);

    Console.WriteLine(stopwatch.ElapsedMilliseconds);
}

在code以上大约需要。 250毫秒,而同样code与的HttpClient JsonSerializer 需要30-45ms。 250ms的是太多的时间仅有4文件。

The code above takes approx. 250ms, while the same code with HttpClient and JsonSerializer takes 30-45ms. 250ms is too much time for just 4 documents.

可以嵌套用在高流量的新闻网站,还是你推荐的HttpClient + JsonSerializer 组合?搜索页的最在2013年访问过我们的网站页面。

Can NEST be used on high-traffic news website, or do you recommend HttpClient + JsonSerializer combo? The search page was the most visited page on our website in 2013.

在此先感谢。

推荐答案

有两件事情要发生,以便NEST做的第一个请求。

There are two things that have to happen in order for NEST to make the first request.

  1. 在JSON序列(Json.net)在这种情况下,有缓存的类型,以便它知道如何序列化和反序列化您发送来回的对象。

  1. The Json Serializer (Json.net) in this case has to cache the type so that it knows how to serialize and deserialize the object you are sending back and forth.

巢有它自己的流利的语言必须从intial类型重新present流畅查询语言和交付JSON来弹性搜索被翻译的查询。这些文件类型也必须由JSON序列学习。

Nest has its own fluent language for queries that must be translated from the intial types that represent the fluent query language and the delivered as JSON to elastic search. These document types also must be learned by the Json Serializer.

在HTTP客户端已被剥离至发出请求。

The HTTP client has to be spun up to make the request.

我目前有超过4M的文件,在我和NEST和我的搜索所有的方式在互联网上使用从服务器到客户端的单一指标正在使用NEST 50-70毫秒。和你一样,不过,感冒后启动的第一个请求是缓慢的。

I currently have over 4M documents in a single index that I use with NEST and my searches from server all the way to client over the internet are taking 50-70 ms using NEST. Like you, however, after a cold start the first request is slow.

这篇关于Elasticsearch和.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆