# Java way to analyze a field with two analyzers

**URL:** <https://discuss.elastic.co/t/java-way-to-analyze-a-field-with-two-analyzers/299050>\
**Category:** Elasticsearch\
**Created:** [March 8, 2022, 7:54am UTC](https://discuss.elastic.co/t/java-way-to-analyze-a-field-with-two-analyzers/299050 "2022-03-08T07:54:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dishant.sharma](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@dishant.sharma](https://discuss.elastic.co/u/dishant.sharma)\
**Post date:** [March 8, 2022, 7:54am UTC](https://discuss.elastic.co/t/java-way-to-analyze-a-field-with-two-analyzers/299050/1 "2022-03-08T07:54:55Z")

</div>

I want to analyze an email with two different custom analyzers at the same time. One analyzer will extract the words from it and another one will extract the special characters from it. And, I want to return the result returned with both the analyzers in a single JSON response. Anyone have any idea how to achieve this?

---

<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:** [March 8, 2022, 9:44am UTC](https://discuss.elastic.co/t/java-way-to-analyze-a-field-with-two-analyzers/299050/2 "2022-03-08T09:44:44Z")

</div>

You can create a subfield for you field.  
The main field will use one analyzer and the sub field the other one.  
But I'm not sure you can get back how it has been analyzed within the `_search` API.  
The `_analyze` API does that though.

---

<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:** [April 5, 2022, 9:45am UTC](https://discuss.elastic.co/t/java-way-to-analyze-a-field-with-two-analyzers/299050/3 "2022-04-05T09:45:19Z")

</div>

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