# Elasticsearch request with c# NEST POST

**URL:** <https://discuss.elastic.co/t/elasticsearch-request-with-c-nest-post/173112>\
**Category:** Elasticsearch\
**Created:** [March 20, 2019, 10:23am UTC](https://discuss.elastic.co/t/elasticsearch-request-with-c-nest-post/173112 "2019-03-20T10:23:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Philippe\_Schaeffer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/philippe_schaeffer/32/42409_2.png) [@Philippe\_Schaeffer](https://discuss.elastic.co/u/Philippe_Schaeffer)\
**Post date:** [March 20, 2019, 10:23am UTC](https://discuss.elastic.co/t/elasticsearch-request-with-c-nest-post/173112/1 "2019-03-20T10:23:44Z")

</div>

Hello,  
Sorry to disturb you but I'm totally blocked, I'm french student and I work on a project in my company.  
I want to make a query in c# on elasticsearch.  
The adress which I can have a json response is:  
X.X.X.X:5602/elasticsearch/collector\_reparation\_\*/reparation/\_search  
I would like to do something like:

Uri node = new Uri("[http://X.X.X.X:5602/elasticsearch/](http://X.X.X.X:5602/elasticsearch/)");  
ConnectionSettings settings = new ConnectionSettings(node);  
settings.SetDeafultIndex("collector\_reparation\_\*);  
var searchResponse = client.Search..????? nothing works  
I'm totally distraught even with the official doc.

Can someone help me to improve please?

I would like to recover all the 'reparations' whose 'etat' = 'effectué' in format raw json (or serialized)

thanks very much in advance...

Sincerely

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [March 20, 2019, 12:23pm UTC](https://discuss.elastic.co/t/elasticsearch-request-with-c-nest-post/173112/2 "2019-03-20T12:23:39Z")

</div>

What version of Elasticsearch are you targeting?

Also, please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

This is the icon to use if you are not using markdown format:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

You can see how it looks in the live preview panel on the right

---

<div class="post-metadata">

**Author:** ![siradude](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@siradude](https://discuss.elastic.co/u/siradude)\
**Post date:** [March 21, 2019, 6:52pm UTC](https://discuss.elastic.co/t/elasticsearch-request-with-c-nest-post/173112/3 "2019-03-21T18:52:09Z")

</div>

Without Stepping in @forloop toes 😐 and I would wait on his guided response!

My limited knowledge and lack of more info might suggest this?

```
var settings = new ConnectionSettings(new Uri("http://x.x.x.x:5602")).DefaultIndex("collector_reparation_*").DefaultTypeName("reparation");
var client = new ElasticClient(settings);
var searchResponse = client.Search<Reparation>(s => s
         .Query(q => q
             .Match(m => m
                .Field(f => f.Etat)
                .Query("effectué")
             )
        )
        );
var responseJson = searchResponse;

     public class Reparation
    {
        public string Etat { get; set; }
    }

```

Hope this helps in any way possible

I assumed in your URI that "ElasticSearch" was the cluster.name (I left it out since I dont know how to specify a Cluster.Name in the Connectionstring, that all index searched start with "collector\_reparation\_" , "reparation is a Type and you have a string field called "etat" in your index.

Here some info in connecting to a node not in (localhost:9200)  
[Connecting](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/connecting.html)

Choosing the right connection strategy  
Sorry I can't be of more help..

---

<div class="post-metadata">

**Author:** ![Philippe\_Schaeffer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/philippe_schaeffer/32/42409_2.png) [@Philippe\_Schaeffer](https://discuss.elastic.co/u/Philippe_Schaeffer)\
**Post date:** [March 28, 2019, 9:58pm UTC](https://discuss.elastic.co/t/elasticsearch-request-with-c-nest-post/173112/4 "2019-03-28T21:58:41Z")

</div>

Thank you very much and sorry to answer so late.  
It's very nice for you to give me some time.  
I'm going back to my company on Monday and I will try it.  
I will let you know.  
Thanks!!!

---

<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:** [April 25, 2019, 9:58pm UTC](https://discuss.elastic.co/t/elasticsearch-request-with-c-nest-post/173112/5 "2019-04-25T21:58:44Z")

</div>

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