# High Level Rest Client - Setting custom tokenizer

**URL:** <https://discuss.elastic.co/t/high-level-rest-client-setting-custom-tokenizer/198754>\
**Category:** Elasticsearch\
**Created:** [September 9, 2019, 5:45pm UTC](https://discuss.elastic.co/t/high-level-rest-client-setting-custom-tokenizer/198754 "2019-09-09T17:45:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![linus](https://avatars.discourse-cdn.com/v4/letter/l/f4b2a3/32.png) [@linus](https://discuss.elastic.co/u/linus)\
**Post date:** [September 9, 2019, 5:45pm UTC](https://discuss.elastic.co/t/high-level-rest-client-setting-custom-tokenizer/198754/1 "2019-09-09T17:45:59Z")

</div>

I am trying to set a custom Tokenizer to my index using the Java High Level Rest Client.

I have been looking through the API documentation, but can't find anything aside from the normal REST calls as mentioned in the guide:

[https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-custom-analyzer.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-custom-analyzer.html)

There are guides to updating index settings here:

[https://www.elastic.co/guide/en/elasticsearch/client/java-rest/master/java-rest-high-indices-put-settings.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/master/java-rest-high-indices-put-settings.html)

But I can't find any examples on tokenizers. Maybe I have missed a documentation somewhere?

---

<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:** [September 10, 2019, 11:54am UTC](https://discuss.elastic.co/t/high-level-rest-client-setting-custom-tokenizer/198754/2 "2019-09-10T11:54:45Z")

</div>

There is not a specific way to generate that. But you can provide a JSON which contains all the index settings, including analyzers like:

> <https://github.com/dadoonet/elasticsearch-beyonder/blob/master/src/test/resources/models/settingsanalyzer/twitter/_settings.json>

Then use the Low Level Client like this:

> <https://github.com/dadoonet/elasticsearch-beyonder/blob/master/src/main/java/fr/pilato/elasticsearch/tools/index/IndexElasticsearchUpdater.java#L276-L297>

Or use the High Level client like this:

> <https://github.com/dadoonet/fscrawler/blob/master/elasticsearch-client/elasticsearch-client-v7/src/main/java/fr/pilato/elasticsearch/crawler/fs/client/v7/ElasticsearchClientV7.java#L211-L229>

HTH

---

<div class="post-metadata">

**Author:** ![linus](https://avatars.discourse-cdn.com/v4/letter/l/f4b2a3/32.png) [@linus](https://discuss.elastic.co/u/linus)\
**Post date:** [September 10, 2019, 3:14pm UTC](https://discuss.elastic.co/t/high-level-rest-client-setting-custom-tokenizer/198754/3 "2019-09-10T15:14:01Z")

</div>

Ah, okay. So there's no way to do it directly through the Java API. Will do it the JSON way like you suggested.

Cheers!

---

<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:** [September 10, 2019, 4:40pm UTC](https://discuss.elastic.co/t/high-level-rest-client-setting-custom-tokenizer/198754/4 "2019-09-10T16:40:25Z")

</div>

There is a way but not with a nice API. as you saw in docs, you can use something like:

```auto
Settings settings =
        Settings.builder()
        .put("analysis.analyzer.custom_uax_url_email.type", "custom")
        .put("analysis.analyzer.custom_uax_url_email.tokenizer", "uax_url_email")
        // And so on...
        .build();

```

---

<div class="post-metadata">

**Author:** ![linus](https://avatars.discourse-cdn.com/v4/letter/l/f4b2a3/32.png) [@linus](https://discuss.elastic.co/u/linus)\
**Post date:** [September 10, 2019, 4:45pm UTC](https://discuss.elastic.co/t/high-level-rest-client-setting-custom-tokenizer/198754/5 "2019-09-10T16:45:09Z")

</div>

I see. I will give that a try to.

Thank you!

---

<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:** [October 8, 2019, 4:52pm UTC](https://discuss.elastic.co/t/high-level-rest-client-setting-custom-tokenizer/198754/6 "2019-10-08T16:52:50Z")

</div>

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