Why use NEST client in C# and not directly query elastic search server through elastic search JSON query?

前端 未结 2 1170
感情败类
感情败类 2021-01-25 22:56

We always create elastic search query in sense and then create corresponding version of it in NEST.

What is benefit of using NEST client and not directly putting JSON e

2条回答
  •  一个人的身影
    2021-01-25 23:33

    There are 2 major reasons to use a strongly typed library like NEST.

    1. It protects you from attempting most invalid requests

    The DSL can feel cumbersome at first, but once you get used to it you realize that it's strict structure prevents you from chaining filters and aggregations together in an invalid way. This means that errors can be caught when you're writing the code, and ready to fix it...and not later in production.

    #2 Give IDEs like Visual Studio and Code everything they need for code completion

    Just like Kibana helps you writing Elasticsearch queries in the dev tools, your IDE can provide syntax highlighting and code completion that can save you time running back and forth to the docs or Kibana. This is really useful when you are dynamically constructing queries.

    Source: I wrote a blog about this recently, on the benefits of using a strongly-typed library like NEST for generating Elasticsearch queries

提交回复
热议问题