# How to write a multi-lined script in C# / Nest?

**URL:** <https://discuss.elastic.co/t/how-to-write-a-multi-lined-script-in-c-nest/317907>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [November 1, 2022, 2:48pm UTC](https://discuss.elastic.co/t/how-to-write-a-multi-lined-script-in-c-nest/317907 "2022-11-01T14:48:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcus\_Bullock](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcus_bullock/32/100571_2.png) [@Marcus\_Bullock](https://discuss.elastic.co/u/Marcus_Bullock)\
**Post date:** [November 1, 2022, 2:48pm UTC](https://discuss.elastic.co/t/how-to-write-a-multi-lined-script-in-c-nest/317907/1 "2022-11-01T14:48:38Z")

</div>

Hi all,

I am trying to write a statement like this but in Nest / C# object initializer syntax:

```auto
GET /_search
{
  "query": {
    "bool": {
      "filter": {
        "script": {
          "script": """
            double amount = doc['amount'].value;
            if (doc['type'].value == 'expense') {
              amount *= -1;
            }
            return amount < 10;
          """
        }
      }
    }
  }
}

```

There are no docs that describe how to set up a multi line script in C# / Nest, from what I've seen the docs only show [a basic maths operation](https://www.elastic.co/guide/en/elasticsearch/client/net-api/7.17/script-fields-usage.html) without going in to more detail.

If someone could translate the example in the code blocks above ([first example in these docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-script-query.html#script-query-ex-request)), I would be most grateful.

---

<div class="post-metadata">

**Author:** ![Marcus\_Bullock](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcus_bullock/32/100571_2.png) [@Marcus\_Bullock](https://discuss.elastic.co/u/Marcus_Bullock)\
**Post date:** [November 2, 2022, 9:53am UTC](https://discuss.elastic.co/t/how-to-write-a-multi-lined-script-in-c-nest/317907/2 "2022-11-02T09:53:07Z")

</div>

Sorry to bump but I can't find any documentation anywhere or on StackOverflow.

In all honesty, the .NET documentation is a bit thin for Elastic and would love to see more C#/Nest implementations of all the examples in the docs.

---

<div class="post-metadata">

**Author:** ![Marcus\_Bullock](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcus_bullock/32/100571_2.png) [@Marcus\_Bullock](https://discuss.elastic.co/u/Marcus_Bullock)\
**Post date:** [November 7, 2022, 2:51pm UTC](https://discuss.elastic.co/t/how-to-write-a-multi-lined-script-in-c-nest/317907/3 "2022-11-07T14:51:45Z")

</div>

Bumping again, sorry!

Surely there must be someone at Elastic who can give some actual documentation on how to use their own product with C#?!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 5, 2022, 2:52pm UTC](https://discuss.elastic.co/t/how-to-write-a-multi-lined-script-in-c-nest/317907/4 "2022-12-05T14:52:07Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
