Nest - Search path

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.

No you can't do that IMO.

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

1 Like

Well, I suppose I was expecting that kind of answer :sweat_smile:

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

I would not expect this to be possible.

Could you run the following requests on your cluster?

GET /
GET /_cat/plugins?v

And share the outputs here?

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.

Could you share one typical output of a search request?

{
    "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": {
                    (...)
                }
            }
        ]
    }
}

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

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?

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.

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

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)

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)
);
1 Like

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