# Get analyzer from client

**URL:** <https://discuss.elastic.co/t/get-analyzer-from-client/20081>\
**Category:** Elasticsearch\
**Created:** [October 5, 2014, 5:48pm UTC](https://discuss.elastic.co/t/get-analyzer-from-client/20081 "2014-10-05T17:48:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pawel\_Rog](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pawel_rog/32/141223_2.png) [@Pawel\_Rog](https://discuss.elastic.co/u/Pawel_Rog)\
**Post date:** [October 5, 2014, 5:48pm UTC](https://discuss.elastic.co/t/get-analyzer-from-client/20081/1 "2014-10-05T17:48:43Z")

</div>

Hi,

I have a java application which uses Elasticsearch client (transport  
client). I need to analyze string taking mapping which is used by ES. I  
know I can prepare analyze request to elasticsearch but it means a lot of  
requests to ES. Is it possible to get somehow Lucene Analyzer from client  
object and then use it to build TokenStream?

--  
Paweł Róg

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbNXoz3bX0AV1d1foSimx8xOFVniwKzz3o9RYvGK6V%3D4Fw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbNXoz3bX0AV1d1foSimx8xOFVniwKzz3o9RYvGK6V%3D4Fw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [October 5, 2014, 6:28pm UTC](https://discuss.elastic.co/t/get-analyzer-from-client/20081/2 "2014-10-05T18:28:45Z")

</div>

The AnalysisService is server-side only and not available in clients.

Jörg

On Sun, Oct 5, 2014 at 7:48 PM, Pawel [prog88@gmail.com](mailto:prog88@gmail.com) wrote:

> Hi,
> 
> I have a java application which uses Elasticsearch client (transport  
> client). I need to analyze string taking mapping which is used by ES. I  
> know I can prepare analyze request to elasticsearch but it means a lot of  
> requests to ES. Is it possible to get somehow Lucene Analyzer from client  
> object and then use it to build TokenStream?
> 
> --  
> Paweł Róg
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbNXoz3bX0AV1d1foSimx8xOFVniwKzz3o9RYvGK6V%3D4Fw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbNXoz3bX0AV1d1foSimx8xOFVniwKzz3o9RYvGK6V%3D4Fw%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbNXoz3bX0AV1d1foSimx8xOFVniwKzz3o9RYvGK6V%3D4Fw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbNXoz3bX0AV1d1foSimx8xOFVniwKzz3o9RYvGK6V%3D4Fw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoE4ivV2WGfMRx%3DBH4HRFxHxGHuvc2T4jiHNsp1izyxbYA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoE4ivV2WGfMRx%3DBH4HRFxHxGHuvc2T4jiHNsp1izyxbYA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [October 6, 2014, 2:54am UTC](https://discuss.elastic.co/t/get-analyzer-from-client/20081/3 "2014-10-06T02:54:48Z")

</div>

It is definitely possible. You can create the analysis service locally and  
query it for the appropriate analyzers. I use this method the pre-analyze  
terms for span queries, which does not analyze text. You would need a local  
copy of your elasticsearch.yml and related files (stopwords, synonyms, etc)  
or redefine everything in code.

Look at the existing test code for how to create an analysis service via  
the guice injector. For example:

[https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java](https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java)

Cheers,

Ivan  
On Oct 5, 2014 10:48 AM, "Pawel" [prog88@gmail.com](mailto:prog88@gmail.com) wrote:

> Hi,
> 
> I have a java application which uses Elasticsearch client (transport  
> client). I need to analyze string taking mapping which is used by ES. I  
> know I can prepare analyze request to elasticsearch but it means a lot of  
> requests to ES. Is it possible to get somehow Lucene Analyzer from client  
> object and then use it to build TokenStream?
> 
> --  
> Paweł Róg
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbNXoz3bX0AV1d1foSimx8xOFVniwKzz3o9RYvGK6V%3D4Fw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbNXoz3bX0AV1d1foSimx8xOFVniwKzz3o9RYvGK6V%3D4Fw%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbNXoz3bX0AV1d1foSimx8xOFVniwKzz3o9RYvGK6V%3D4Fw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbNXoz3bX0AV1d1foSimx8xOFVniwKzz3o9RYvGK6V%3D4Fw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQByAQdaWc3GpLun-5y\_Z62Vx3qEZ7W%3DABON8-z5PCaM6g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQByAQdaWc3GpLun-5y_Z62Vx3qEZ7W%3DABON8-z5PCaM6g%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Pawel\_Rog](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pawel_rog/32/141223_2.png) [@Pawel\_Rog](https://discuss.elastic.co/u/Pawel_Rog)\
**Post date:** [October 6, 2014, 6:50am UTC](https://discuss.elastic.co/t/get-analyzer-from-client/20081/4 "2014-10-06T06:50:40Z")

</div>

Hi,  
Thank you for all of those suggestions. I think this will work for me.

--  
Paweł Róg

On Mon, Oct 6, 2014 at 4:54 AM, Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com) wrote:

> It is definitely possible. You can create the analysis service locally and  
> query it for the appropriate analyzers. I use this method the pre-analyze  
> terms for span queries, which does not analyze text. You would need a local  
> copy of your elasticsearch.yml and related files (stopwords, synonyms, etc)  
> or redefine everything in code.
> 
> Look at the existing test code for how to create an analysis service via  
> the guice injector. For example:
> 
> [https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java](https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java)
> 
> Cheers,
> 
> Ivan  
> On Oct 5, 2014 10:48 AM, "Pawel" [prog88@gmail.com](mailto:prog88@gmail.com) wrote:
> 
> > Hi,
> > 
> > I have a java application which uses Elasticsearch client (transport  
> > client). I need to analyze string taking mapping which is used by ES. I  
> > know I can prepare analyze request to elasticsearch but it means a lot of  
> > requests to ES. Is it possible to get somehow Lucene Analyzer from client  
> > object and then use it to build TokenStream?
> > 
> > --  
> > Paweł Róg
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbNXoz3bX0AV1d1foSimx8xOFVniwKzz3o9RYvGK6V%3D4Fw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbNXoz3bX0AV1d1foSimx8xOFVniwKzz3o9RYvGK6V%3D4Fw%40mail.gmail.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbNXoz3bX0AV1d1foSimx8xOFVniwKzz3o9RYvGK6V%3D4Fw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbNXoz3bX0AV1d1foSimx8xOFVniwKzz3o9RYvGK6V%3D4Fw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQByAQdaWc3GpLun-5y\_Z62Vx3qEZ7W%3DABON8-z5PCaM6g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQByAQdaWc3GpLun-5y_Z62Vx3qEZ7W%3DABON8-z5PCaM6g%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQByAQdaWc3GpLun-5y\_Z62Vx3qEZ7W%3DABON8-z5PCaM6g%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQByAQdaWc3GpLun-5y_Z62Vx3qEZ7W%3DABON8-z5PCaM6g%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbPBjn-k6y\_G4R4C0H4Yx%2B0yVFJvPf4kCn9LJ%3DrS-gx8eQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAF9ZkbPBjn-k6y_G4R4C0H4Yx%2B0yVFJvPf4kCn9LJ%3DrS-gx8eQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:58am UTC](https://discuss.elastic.co/t/get-analyzer-from-client/20081/5 "2017-07-06T00:58:10Z")

</div>


