# Analyze Request - Local parameter

**URL:** <https://discuss.elastic.co/t/analyze-request-local-parameter/209532>\
**Category:** Elasticsearch\
**Created:** [November 26, 2019, 2:29pm UTC](https://discuss.elastic.co/t/analyze-request-local-parameter/209532 "2019-11-26T14:29:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gri/32/41433_2.png) [@gri](https://discuss.elastic.co/u/gri)\
**Post date:** [November 26, 2019, 2:29pm UTC](https://discuss.elastic.co/t/analyze-request-local-parameter/209532/1 "2019-11-26T14:29:44Z")

</div>

The Analyze endpoint does not seem to have a "local" parameter to specify the preference.  
Is it just missing or is that on purpose and I am missing something?

I noticed it was possible in the 0.\* and 1.\* versions of ES and was then removed after that.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [November 28, 2019, 9:15am UTC](https://discuss.elastic.co/t/analyze-request-local-parameter/209532/2 "2019-11-28T09:15:45Z")

</div>

The analyze endpoint does not access any data on a shard, so there is no need for such parameter. It only needs to access the mapping configuration if you specify an index in a request in order to be able to read the analyzer that may be configured in a request.

Maybe you can explain why you think it is needed to make sure we get rid of any confusion.

---

<div class="post-metadata">

**Author:** ![gri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gri/32/41433_2.png) [@gri](https://discuss.elastic.co/u/gri)\
**Post date:** [November 28, 2019, 11:42am UTC](https://discuss.elastic.co/t/analyze-request-local-parameter/209532/3 "2019-11-28T11:42:51Z")

</div>

I was setting parameters for requests and I was expecting to have a parameter local as preference.  
I noticed it was removed in 2.0 so I looked at the code and if I understand correctly

```
An AnalyzeRequest is sent to a node.
If an index was specified, then it is sent to a random node (that must have a shard of the index)
  See TransportAnalyzeAction:shards
  See TransportSingleShardAction.AsyncSingleAction:perform
Else it is sent to the local node 

```

Why not have the possibility to send it to the local node as a preference  
I ask this because when I typed it, I ended up on a "preferLocal" option that was present in ES 1.7

For the equivalent code (TransportSingleCustomOperationAction.AsyncSingleAction:performFirst)

```
  If no index specified, it executes on the local node as newer versions
  Else
    if preferLocalShard, then it executes it on the local node (with a shard of the index)
    Else or if local node is a not appropriate, it is similar to newer versions

```

The comment of the method even specifies: "First get should try and use a shard that exists on a local node for better performance"  
So I was wondering why it was removed in ES 2.0

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [November 28, 2019, 1:04pm UTC](https://discuss.elastic.co/t/analyze-request-local-parameter/209532/4 "2019-11-28T13:04:44Z")

</div>

it looks as it has been removed by a refactoring 7 years ago, see [https://github.com/elastic/elasticsearch/commit/cfe7504d1cee2cffd3ed06c3b61d0c77de63b67f](https://github.com/elastic/elasticsearch/commit/cfe7504d1cee2cffd3ed06c3b61d0c77de63b67f)

I don't think you will gain too much by adding this parameter back, as this API is not supposed to be called very often except for debugging issues.

---

<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 26, 2019, 1:04pm UTC](https://discuss.elastic.co/t/analyze-request-local-parameter/209532/5 "2019-12-26T13:04:54Z")

</div>

Closed on December 26, 2019, 1:04pm UTC

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