# Nest - Search path

**URL:** <https://discuss.elastic.co/t/nest-search-path/273946>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [May 25, 2021, 1:36pm UTC](https://discuss.elastic.co/t/nest-search-path/273946 "2021-05-25T13:36:04Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![silentw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/silentw/32/89246_2.png) [@silentw](https://discuss.elastic.co/u/silentw)\
**Post date:** [May 25, 2021, 1:36pm UTC](https://discuss.elastic.co/t/nest-search-path/273946/1 "2021-05-25T13:36:04Z")

</div>

I am trying to use the Nest client to consume an Elasticsearch instance.

However, the `/_search` endpoint is in fact `/search` .

Is there any possible way to change the behavior of the client to reflect this change?

I have tried looking into the source code but just can't figure out a way this can be done.

Disclaimer: I have no control over the ES instance, neither I know if there is some sort of proxy in the middle that alters the `/_search` into `/search` .

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 25, 2021, 1:51pm UTC](https://discuss.elastic.co/t/nest-search-path/273946/2 "2021-05-25T13:51:55Z")

</div>

No you can't do that IMO.

You could add another proxy on top of your proxy which rewrites `/_search` to `/search`. 😬

---

<div class="post-metadata">

**Author:** ![silentw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/silentw/32/89246_2.png) [@silentw](https://discuss.elastic.co/u/silentw)\
**Post date:** [May 25, 2021, 1:55pm UTC](https://discuss.elastic.co/t/nest-search-path/273946/3 "2021-05-25T13:55:12Z")

</div>

Well, I suppose I was expecting that kind of answer 😅

So... There is no way I can change the `/_search` path on the client?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 25, 2021, 2:22pm UTC](https://discuss.elastic.co/t/nest-search-path/273946/4 "2021-05-25T14:22:58Z")

</div>

I would not expect this to be possible.

Could you run the following requests on your cluster?

```auto
GET /
GET /_cat/plugins?v

```

And share the outputs here?

---

<div class="post-metadata">

**Author:** ![silentw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/silentw/32/89246_2.png) [@silentw](https://discuss.elastic.co/u/silentw)\
**Post date:** [May 25, 2021, 2:48pm UTC](https://discuss.elastic.co/t/nest-search-path/273946/5 "2021-05-25T14:48:23Z")

</div>

I guess this is a "protected" environment of elasticsearch, where only some endpoints are available. I assume they only allow the `search` route, which is basically `_search` rewritten to `search`.

I'm trying to grab more information from the provider.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 25, 2021, 3:00pm UTC](https://discuss.elastic.co/t/nest-search-path/273946/6 "2021-05-25T15:00:24Z")

</div>

Could you share one typical output of a search request?

---

<div class="post-metadata">

**Author:** ![silentw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/silentw/32/89246_2.png) [@silentw](https://discuss.elastic.co/u/silentw)\
**Post date:** [May 25, 2021, 3:18pm UTC](https://discuss.elastic.co/t/nest-search-path/273946/7 "2021-05-25T15:18:19Z")

</div>

```auto
{
    "took": 1,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": 1,
        "max_score": [SCORE],
        "hits": [
            {
                "_index": "transcripts",
                "_type": "transcript",
                "_id": "[ID]",
                "_score": [SCORE],
                "_source": {
                    (...)
                }
            }
        ]
    }
}

```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 25, 2021, 4:08pm UTC](https://discuss.elastic.co/t/nest-search-path/273946/8 "2021-05-25T16:08:07Z")

</div>

Hmmm. So it's an old version of elasticsearch...

What are the other APIs available?  
What do you get back when you call something like:

```
GET /donotexist
```

---

<div class="post-metadata">

**Author:** ![silentw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/silentw/32/89246_2.png) [@silentw](https://discuss.elastic.co/u/silentw)\
**Post date:** [May 25, 2021, 4:34pm UTC](https://discuss.elastic.co/t/nest-search-path/273946/9 "2021-05-25T16:34:58Z")

</div>

Some extra information:

The version is 6.2.3.  
It seems that the `/transcripts/search` endpoint is not a "true" elasticsearch endpoint, but combines multiple information into one single endpoint. For example, while the transcript is a valid `Type`, originally does not contain all the information that is returned in this endpoint.

Am I out of luck in using the NEST Client, even if I somehow can get them to make `/_search` available?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 25, 2021, 8:44pm UTC](https://discuss.elastic.co/t/nest-search-path/273946/10 "2021-05-25T20:44:46Z")

</div>

I don't know this client.  
In the LowLevel Java client you can call whatever endpoint so I guess this could work.

I don't know if the `Elasticsearch.Net` client exposes similar low level GET/POST calls.

---

<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:** [May 26, 2021, 1:18am UTC](https://discuss.elastic.co/t/nest-search-path/273946/11 "2021-05-26T01:18:28Z")

</div>

> [@dadoonet](#):
>
> I don't know if the `Elasticsearch.Net` client exposes similar low level GET/POST calls.

It does! I answered this same question on Stack Overflow:

> <https://stackoverflow.com/questions/67687643/nest-search-path/67697283#67697283>

I'll include it here for completeness.

* * *

`/search` is not an API endpoint in Elasticsearch. It is not possible to change the API endpoints within the client, without changing the API specs from which it is generated and recompiling.

You _can_ use the low level client's `DoRequest` and `DoRequestAsync` methods to call  
a non-standard API.

With the 6.x or 7.x client ( **you should use the 6.x client with 6.2.3** )

```auto
var client = new ElasticClient();
	
var request = new SearchRequest<LogMessage>
{
	Query = new MatchQuery
	{
		Field = Infer.Field<LogMessage>(f => f.Level),
		Query = "warning"
	}
};
	
var response = client.LowLevel.DoRequest<SearchResponse<LogMessage>>(
	Elasticsearch.Net.HttpMethod.POST, 
	"/search", 
	PostData.Serializable<ISearchRequest>(request)
);

```

---

<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:** [June 23, 2021, 1:19am UTC](https://discuss.elastic.co/t/nest-search-path/273946/12 "2021-06-23T01:19:11Z")

</div>

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