# Set custom analyzer with Java API

**URL:** <https://discuss.elastic.co/t/set-custom-analyzer-with-java-api/29875>\
**Category:** Elasticsearch\
**Created:** [September 23, 2015, 9:34pm UTC](https://discuss.elastic.co/t/set-custom-analyzer-with-java-api/29875 "2015-09-23T21:34:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zoltan](https://avatars.discourse-cdn.com/v4/letter/z/ad7895/32.png) [@zoltan](https://discuss.elastic.co/u/zoltan)\
**Post date:** [September 23, 2015, 9:34pm UTC](https://discuss.elastic.co/t/set-custom-analyzer-with-java-api/29875/1 "2015-09-23T21:34:26Z")

</div>

Hi There!

I'm building a Java Map with a content like this as I'd like to set a custom analyzer:

> {index={analysis={analyzer=[{whitespace\_lowercase={filter=whitespace , type=custom, tokenizer=whitespace }}]}}}

But when I try to create the index with this map like this:

```
CreateIndexRequestBuilder createIndexRequestBuilder = elasticClient.admin().indices().prepareCreate("test");

CreateIndexResponse resp = createIndexRequestBuilder.setSettings(theJavaMap).execute().actionGet();

```

Then I get an error:

```
java.lang.IllegalArgumentException: Analyzer [0] must have a type associated with it

```

Does anyone have an idea how the hell should I make this work? Does Elasticsearch has a better programmatic API than json building/map for creating analyzers?

Thanks,  
Zoltan

PS: I'm using elastic 2.x.x beta

---

<div class="post-metadata">

**Author:** ![zoltan](https://avatars.discourse-cdn.com/v4/letter/z/ad7895/32.png) [@zoltan](https://discuss.elastic.co/u/zoltan)\
**Post date:** [September 23, 2015, 10:48pm UTC](https://discuss.elastic.co/t/set-custom-analyzer-with-java-api/29875/2 "2015-09-23T22:48:11Z")

</div>

Eventually I found the solution. The problem was that the analyzer field contained an array of objects, however that must be strictly an object.

---

<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:** [July 5, 2017, 11:48pm UTC](https://discuss.elastic.co/t/set-custom-analyzer-with-java-api/29875/3 "2017-07-05T23:48:25Z")

</div>


