# Analyze API available through Java?

**URL:** <https://discuss.elastic.co/t/analyze-api-available-through-java/9566>\
**Category:** Elasticsearch\
**Created:** [November 5, 2012, 7:45pm UTC](https://discuss.elastic.co/t/analyze-api-available-through-java/9566 "2012-11-05T19:45:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erick\_Lee](https://avatars.discourse-cdn.com/v4/letter/e/dbc845/32.png) [@Erick\_Lee](https://discuss.elastic.co/u/Erick_Lee)\
**Post date:** [November 5, 2012, 7:45pm UTC](https://discuss.elastic.co/t/analyze-api-available-through-java/9566/1 "2012-11-05T19:45:34Z")

</div>

Hi,

Is there a version of the analyze api available to the Java client? I  
looked around and didn't find it.

I'd like to search for documents that start with a phrase. SpanFirst looks  
like it lets me search for terms at the start, so I'd like to run the  
phrase through the analyzer for the field.

Thanks!

--

---

<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:** [November 5, 2012, 8:05pm UTC](https://discuss.elastic.co/t/analyze-api-available-through-java/9566/2 "2012-11-05T20:05:25Z")

</div>

Hi Erick,

have a look at the integration tests  
in org.elasticsearch.test.integration.indices.analyze, then you find an  
example

AnalyzeResponse analyzeResponse = client.admin().indices().prepareAnalyze(  
"test", "this is a test").execute().actionGet();  
Cheers,

Jörg

On Monday, November 5, 2012 8:45:34 PM UTC+1, Erick Lee wrote:

> Hi,
> 
> Is there a version of the analyze api available to the Java client? I  
> looked around and didn't find it.
> 
> I'd like to search for documents that start with a phrase. SpanFirst  
> looks like it lets me search for terms at the start, so I'd like to run the  
> phrase through the analyzer for the field.
> 
> Thanks!

--

---

<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:** [November 5, 2012, 8:19pm UTC](https://discuss.elastic.co/t/analyze-api-available-through-java/9566/3 "2012-11-05T20:19:44Z")

</div>

I recreate the AnalysisModule locally and call it directly, avoiding the  
network hop to Elasticsearch. It all depends on how many calls you make to  
ES.

When in doubt with the Java API, look for the Rest\*Action Java class (in  
your case RestAnalyzeAction), or the tests as Jörg pointed out.

--  
Ivan

On Mon, Nov 5, 2012 at 12:05 PM, Jörg Prante [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:

> Hi Erick,
> 
> have a look at the integration tests  
> in org.elasticsearch.test.integration.indices.analyze, then you find an  
> example
> 
> AnalyzeResponse analyzeResponse = client.admin().indices().prepareAnalyze(  
> "test", "this is a test").execute().actionGet();  
> Cheers,
> 
> Jörg
> 
> On Monday, November 5, 2012 8:45:34 PM UTC+1, Erick Lee wrote:
> 
> > Hi,
> > 
> > Is there a version of the analyze api available to the Java client? I  
> > looked around and didn't find it.
> > 
> > I'd like to search for documents that start with a phrase. SpanFirst  
> > looks like it lets me search for terms at the start, so I'd like to run the  
> > phrase through the analyzer for the field.
> > 
> > Thanks!
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Erick\_Lee](https://avatars.discourse-cdn.com/v4/letter/e/dbc845/32.png) [@Erick\_Lee](https://discuss.elastic.co/u/Erick_Lee)\
**Post date:** [November 5, 2012, 8:37pm UTC](https://discuss.elastic.co/t/analyze-api-available-through-java/9566/4 "2012-11-05T20:37:57Z")

</div>

Thanks, that is what I was looking for.

On Monday, November 5, 2012 12:05:26 PM UTC-8, Jörg Prante wrote:

> Hi Erick,
> 
> have a look at the integration tests  
> in org.elasticsearch.test.integration.indices.analyze, then you find an  
> example
> 
> AnalyzeResponse analyzeResponse = client.admin().indices().prepareAnalyze(  
> "test", "this is a test").execute().actionGet();  
> Cheers,
> 
> Jörg
> 
> On Monday, November 5, 2012 8:45:34 PM UTC+1, Erick Lee wrote:
> 
> > Hi,
> > 
> > Is there a version of the analyze api available to the Java client? I  
> > looked around and didn't find it.
> > 
> > I'd like to search for documents that start with a phrase. SpanFirst  
> > looks like it lets me search for terms at the start, so I'd like to run the  
> > phrase through the analyzer for the field.
> > 
> > Thanks!

--

---

<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, 3:06am UTC](https://discuss.elastic.co/t/analyze-api-available-through-java/9566/5 "2017-07-06T03:06:09Z")

</div>


