# Querying with Completion Suggesters with Java API

**URL:** <https://discuss.elastic.co/t/querying-with-completion-suggesters-with-java-api/16822>\
**Category:** Elasticsearch\
**Created:** [April 4, 2014, 2:02pm UTC](https://discuss.elastic.co/t/querying-with-completion-suggesters-with-java-api/16822 "2014-04-04T14:02:19Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bill\_Wortinger](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Bill\_Wortinger](https://discuss.elastic.co/u/Bill_Wortinger)\
**Post date:** [April 4, 2014, 2:02pm UTC](https://discuss.elastic.co/t/querying-with-completion-suggesters-with-java-api/16822/1 "2014-04-04T14:02:19Z")

</div>

I have my indices created, and mapping type for my 'suggest' field set to  
completion. I can't figure out how to configure the query for completion  
suggestions in elastic-search (Java API).

I'm trying to use this Query to base my implementation off of. "song-suggest" : { "text" : "n", "completion" : { "field" : "suggest" } } Here's  
what I have so far,

```
    CompletionSuggestionBuilder compBuilder = new CompletionSuggestionBuilder("complete"); 
    compBuilder.text("n..");
    compBuilder.field("suggest");

    SearchResponse searchResponse = localClient.prepareSearch(INDEX_NAME)
    .setTypes("completion")
    .setQuery(QueryBuilders.matchAllQuery())
    .addSuggestion(compBuilder)
    .execute().actionGet();

     CompletionSuggestion compSuggestion = searchResponse.getSuggest().getSuggestion("complete");

```

Am I missing something, doing something wrong? Thanks!

--  
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/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 7, 2014, 7:49am UTC](https://discuss.elastic.co/t/querying-with-completion-suggesters-with-java-api/16822/2 "2014-04-07T07:49:51Z")

</div>

Hey,

looks ok. Minor note: Types are simply ignored for suggestions. What are  
you getting back? Nothing?  
Can you create a fully working gist, including creation of the mapping and  
indexing? Then debugging and finding your possible cause would be a lot  
easier.

--Alex

On Fri, Apr 4, 2014 at 4:02 PM, Bill Wortinger [r3dreign@gmail.com](mailto:r3dreign@gmail.com) wrote:

> I have my indices created, and mapping type for my 'suggest' field set to  
> completion. I can't figure out how to configure the query for completion  
> suggestions in elastic-search (Java API).
> 
> I'm trying to use this Query to base my implementation off of. "song-suggest" : { "text" : "n", "completion" : { "field" : "suggest" } } Here's  
> what I have so far,
> 
> ```
> CompletionSuggestionBuilder compBuilder = new CompletionSuggestionBuilder("complete");
> compBuilder.text("n..");
> compBuilder.field("suggest");
> 
> SearchResponse searchResponse = localClient.prepareSearch(INDEX_NAME)
> .setTypes("completion")
> .setQuery(QueryBuilders.matchAllQuery())
> .addSuggestion(compBuilder)
> .execute().actionGet();
> 
> CompletionSuggestion compSuggestion = searchResponse.getSuggest().getSuggestion("complete");
> 
> ```
> 
> Am I missing something, doing something wrong? Thanks!
> 
> --  
> 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/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.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/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [April 7, 2014, 10:26am UTC](https://discuss.elastic.co/t/querying-with-completion-suggesters-with-java-api/16822/3 "2014-04-07T10:26:37Z")

</div>

Use the SuggestRequestBuilder, i.e.

CompletionSuggestionBuilder compBuilder = new  
CompletionSuggestionBuilder("complete");  
compBuilder.text("n");  
compBuilder.field("suggest");

SuggestRequestBuilder suggestRequestBuilder =  
client.prepareSuggest(INDEX\_NAME);  
suggestRequestBuilder.addSuggestion(compBuilder);  
SuggestResponse suggestResponse =  
suggestRequestBuilder.execute().actionGet();

Dan

On Mon, Apr 7, 2014 at 8:49 AM, Alexander Reelsen [alr@spinscale.de](mailto:alr@spinscale.de) wrote:

> Hey,
> 
> looks ok. Minor note: Types are simply ignored for suggestions. What are  
> you getting back? Nothing?  
> Can you create a fully working gist, including creation of the mapping and  
> indexing? Then debugging and finding your possible cause would be a lot  
> easier.
> 
> --Alex
> 
> On Fri, Apr 4, 2014 at 4:02 PM, Bill Wortinger [r3dreign@gmail.com](mailto:r3dreign@gmail.com) wrote:
> 
> > I have my indices created, and mapping type for my 'suggest' field set to  
> > completion. I can't figure out how to configure the query for completion  
> > suggestions in elastic-search (Java API).
> > 
> > I'm trying to use this Query to base my implementation off of. "song-suggest" : { "text" : "n", "completion" : { "field" : "suggest" } } Here's  
> > what I have so far,
> > 
> > ```
> > CompletionSuggestionBuilder compBuilder = new CompletionSuggestionBuilder("complete");
> > compBuilder.text("n..");
> > compBuilder.field("suggest");
> > 
> > SearchResponse searchResponse = localClient.prepareSearch(INDEX_NAME)
> > .setTypes("completion")
> > .setQuery(QueryBuilders.matchAllQuery())
> > .addSuggestion(compBuilder)
> > .execute().actionGet();
> > 
> > CompletionSuggestion compSuggestion = searchResponse.getSuggest().getSuggestion("complete");
> > 
> > ```
> > 
> > Am I missing something, doing something wrong? Thanks!
> > 
> > --  
> > 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/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.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/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%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/CAEyth3vRqny8v67fY925TYkd23FnfvAW6mmzobFA1jVv66BCHw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAEyth3vRqny8v67fY925TYkd23FnfvAW6mmzobFA1jVv66BCHw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Bill\_Wortinger](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Bill\_Wortinger](https://discuss.elastic.co/u/Bill_Wortinger)\
**Post date:** [April 8, 2014, 12:42pm UTC](https://discuss.elastic.co/t/querying-with-completion-suggesters-with-java-api/16822/4 "2014-04-08T12:42:55Z")

</div>

Thanks for the heads up Alex, I'll remove the .setTypes().

Dan, this is what I have so far;

CompletionSuggestionBuilder compBuilder = new  
CompletionSuggestionBuilder("complete");  
compBuilder.text('n");  
compBuilder.field("suggest");  
SuggestRequestBuilder suggestRequestBuilder =  
client.prepareSuggest(INDEX\_NAME);  
suggestRequestBuilder.addSuggestion(compBuilder);  
SuggestResponse suggestResponse =  
suggestRequestBuilder.execute().actionGet();

CompletionSuggestion compSuggestion =  
suggestResponse.getSuggest().getSuggestion("complete");

List\<CompletionSuggestion.Entry\> entryList = compSuggestion.getEntries();  
if(entryList != null) {  
CompletionSuggestion.Entry entry = entryList.get(0);  
List\<CompletionSuggestion.Entry.Option\> options =entry.getOptions();  
if(options != null) {  
CompletionSuggestion.Entry.Option option = options.get(0);  
toReturn = option.getText().string();  
}  
}  
return toReturn;

I've made progress! But now it's falling apart when I try parsing the  
entries from the suggestReponse. So, am I doing this correctly? Missing  
something?

Thanks!

On Monday, April 7, 2014 6:26:37 AM UTC-4, Dan wrote:

> Use the SuggestRequestBuilder, i.e.
> 
> CompletionSuggestionBuilder compBuilder = new  
> CompletionSuggestionBuilder("complete");  
> compBuilder.text("n");  
> compBuilder.field("suggest");
> 
> SuggestRequestBuilder suggestRequestBuilder =  
> client.prepareSuggest(INDEX\_NAME);  
> suggestRequestBuilder.addSuggestion(compBuilder);  
> SuggestResponse suggestResponse =  
> suggestRequestBuilder.execute().actionGet();
> 
> Dan
> 
> On Mon, Apr 7, 2014 at 8:49 AM, Alexander Reelsen \<[a...@spinscale.de](mailto:a...@spinscale.de)\<javascript:\>
> 
> > wrote:
> 
> > Hey,
> > 
> > looks ok. Minor note: Types are simply ignored for suggestions. What are  
> > you getting back? Nothing?  
> > Can you create a fully working gist, including creation of the mapping  
> > and indexing? Then debugging and finding your possible cause would be a lot  
> > easier.
> > 
> > --Alex
> > 
> > On Fri, Apr 4, 2014 at 4:02 PM, Bill Wortinger \<[r3dr...@gmail.com](mailto:r3dr...@gmail.com)\<javascript:\>
> > 
> > > wrote:
> > 
> > > I have my indices created, and mapping type for my 'suggest' field set  
> > > to completion. I can't figure out how to configure the query for completion  
> > > suggestions in elastic-search (Java API).
> > > 
> > > I'm trying to use this Query to base my implementation off of. "song-suggest" : { "text" : "n", "completion" : { "field" : "suggest" } } Here's  
> > > what I have so far,
> > > 
> > > ```
> > > CompletionSuggestionBuilder compBuilder = new CompletionSuggestionBuilder("complete"); 
> > > compBuilder.text("n..");
> > > compBuilder.field("suggest");
> > > 
> > > SearchResponse searchResponse = localClient.prepareSearch(INDEX_NAME)
> > > .setTypes("completion")
> > > .setQuery(QueryBuilders.matchAllQuery())
> > > .addSuggestion(compBuilder)
> > > .execute().actionGet();
> > > 
> > > CompletionSuggestion compSuggestion = searchResponse.getSuggest().getSuggestion("complete");
> > > 
> > > ```
> > > 
> > > Am I missing something, doing something wrong? Thanks!
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%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).

On Monday, April 7, 2014 6:26:37 AM UTC-4, Dan wrote:

> Use the SuggestRequestBuilder, i.e.
> 
> CompletionSuggestionBuilder compBuilder = new  
> CompletionSuggestionBuilder("complete");  
> compBuilder.text("n");  
> compBuilder.field("suggest");
> 
> SuggestRequestBuilder suggestRequestBuilder =  
> client.prepareSuggest(INDEX\_NAME);  
> suggestRequestBuilder.addSuggestion(compBuilder);  
> SuggestResponse suggestResponse =  
> suggestRequestBuilder.execute().actionGet();
> 
> Dan
> 
> On Mon, Apr 7, 2014 at 8:49 AM, Alexander Reelsen \<[a...@spinscale.de](mailto:a...@spinscale.de)\<javascript:\>
> 
> > wrote:
> 
> > Hey,
> > 
> > looks ok. Minor note: Types are simply ignored for suggestions. What are  
> > you getting back? Nothing?  
> > Can you create a fully working gist, including creation of the mapping  
> > and indexing? Then debugging and finding your possible cause would be a lot  
> > easier.
> > 
> > --Alex
> > 
> > On Fri, Apr 4, 2014 at 4:02 PM, Bill Wortinger \<[r3dr...@gmail.com](mailto:r3dr...@gmail.com)\<javascript:\>
> > 
> > > wrote:
> > 
> > > I have my indices created, and mapping type for my 'suggest' field set  
> > > to completion. I can't figure out how to configure the query for completion  
> > > suggestions in elastic-search (Java API).
> > > 
> > > I'm trying to use this Query to base my implementation off of. "song-suggest" : { "text" : "n", "completion" : { "field" : "suggest" } } Here's  
> > > what I have so far,
> > > 
> > > ```
> > > CompletionSuggestionBuilder compBuilder = new CompletionSuggestionBuilder("complete"); 
> > > compBuilder.text("n..");
> > > compBuilder.field("suggest");
> > > 
> > > SearchResponse searchResponse = localClient.prepareSearch(INDEX_NAME)
> > > .setTypes("completion")
> > > .setQuery(QueryBuilders.matchAllQuery())
> > > .addSuggestion(compBuilder)
> > > .execute().actionGet();
> > > 
> > > CompletionSuggestion compSuggestion = searchResponse.getSuggest().getSuggestion("complete");
> > > 
> > > ```
> > > 
> > > Am I missing something, doing something wrong? Thanks!
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%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/1ca849e3-b5af-4119-a5ba-090c289af190%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1ca849e3-b5af-4119-a5ba-090c289af190%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Bill\_Wortinger](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Bill\_Wortinger](https://discuss.elastic.co/u/Bill_Wortinger)\
**Post date:** [April 8, 2014, 12:43pm UTC](https://discuss.elastic.co/t/querying-with-completion-suggesters-with-java-api/16822/5 "2014-04-08T12:43:29Z")

</div>

Thanks for the heads up Alex, I'll remove the .setTypes().

Dan, this is what I have so far;

CompletionSuggestionBuilder compBuilder = new  
CompletionSuggestionBuilder("complete");  
compBuilder.text('n");  
compBuilder.field("suggest");  
SuggestRequestBuilder suggestRequestBuilder =  
client.prepareSuggest(INDEX\_NAME);  
suggestRequestBuilder.addSuggestion(compBuilder);  
SuggestResponse suggestResponse =  
suggestRequestBuilder.execute().actionGet();

CompletionSuggestion compSuggestion =  
suggestResponse.getSuggest().getSuggestion("complete");

List\<CompletionSuggestion.Entry\> entryList = compSuggestion.getEntries();  
if(entryList != null) {  
CompletionSuggestion.Entry entry = entryList.get(0);  
List\<CompletionSuggestion.Entry.Option\> options =entry.getOptions();  
if(options != null) {  
CompletionSuggestion.Entry.Option option = options.get(0);  
toReturn = option.getText().string();  
}  
}  
return toReturn;

I've made progress! But now it's falling apart when I try parsing the  
entries from the suggestReponse. So, am I doing this correctly? Missing  
something?

Thanks!

> 

On Monday, April 7, 2014 6:26:37 AM UTC-4, Dan wrote:

> Use the SuggestRequestBuilder, i.e.
> 
> CompletionSuggestionBuilder compBuilder = new  
> CompletionSuggestionBuilder("complete");  
> compBuilder.text("n");  
> compBuilder.field("suggest");
> 
> SuggestRequestBuilder suggestRequestBuilder =  
> client.prepareSuggest(INDEX\_NAME);  
> suggestRequestBuilder.addSuggestion(compBuilder);  
> SuggestResponse suggestResponse =  
> suggestRequestBuilder.execute().actionGet();
> 
> Dan
> 
> On Mon, Apr 7, 2014 at 8:49 AM, Alexander Reelsen \<[a...@spinscale.de](mailto:a...@spinscale.de)\<javascript:\>
> 
> > wrote:
> 
> > Hey,
> > 
> > looks ok. Minor note: Types are simply ignored for suggestions. What are  
> > you getting back? Nothing?  
> > Can you create a fully working gist, including creation of the mapping  
> > and indexing? Then debugging and finding your possible cause would be a lot  
> > easier.
> > 
> > --Alex
> > 
> > On Fri, Apr 4, 2014 at 4:02 PM, Bill Wortinger \<[r3dr...@gmail.com](mailto:r3dr...@gmail.com)\<javascript:\>
> > 
> > > wrote:
> > 
> > > I have my indices created, and mapping type for my 'suggest' field set  
> > > to completion. I can't figure out how to configure the query for completion  
> > > suggestions in elastic-search (Java API).
> > > 
> > > I'm trying to use this Query to base my implementation off of. "song-suggest" : { "text" : "n", "completion" : { "field" : "suggest" } } Here's  
> > > what I have so far,
> > > 
> > > ```
> > > CompletionSuggestionBuilder compBuilder = new CompletionSuggestionBuilder("complete"); 
> > > compBuilder.text("n..");
> > > compBuilder.field("suggest");
> > > 
> > > SearchResponse searchResponse = localClient.prepareSearch(INDEX_NAME)
> > > .setTypes("completion")
> > > .setQuery(QueryBuilders.matchAllQuery())
> > > .addSuggestion(compBuilder)
> > > .execute().actionGet();
> > > 
> > > CompletionSuggestion compSuggestion = searchResponse.getSuggest().getSuggestion("complete");
> > > 
> > > ```
> > > 
> > > Am I missing something, doing something wrong? Thanks!
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%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/1e5d7d0e-763d-4a3d-ab71-39cea5889c84%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1e5d7d0e-763d-4a3d-ab71-39cea5889c84%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [April 8, 2014, 1:14pm UTC](https://discuss.elastic.co/t/querying-with-completion-suggesters-with-java-api/16822/6 "2014-04-08T13:14:29Z")

</div>

What is the issue you're seeing? Have a look at the examples in the tests:

[https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchTests.java](https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchTests.java)

Dan

On Tuesday, April 8, 2014 1:43:29 PM UTC+1, Bill Wortinger wrote:

> Thanks for the heads up Alex, I'll remove the .setTypes().
> 
> Dan, this is what I have so far;
> 
> CompletionSuggestionBuilder compBuilder = new  
> CompletionSuggestionBuilder("complete");  
> compBuilder.text('n");  
> compBuilder.field("suggest");  
> SuggestRequestBuilder suggestRequestBuilder =  
> client.prepareSuggest(INDEX\_NAME);  
> suggestRequestBuilder.addSuggestion(compBuilder);  
> SuggestResponse suggestResponse =  
> suggestRequestBuilder.execute().actionGet();
> 
> CompletionSuggestion compSuggestion =  
> suggestResponse.getSuggest().getSuggestion("complete");
> 
> List\<CompletionSuggestion.Entry\> entryList = compSuggestion.getEntries();  
> if(entryList != null) {  
> CompletionSuggestion.Entry entry = entryList.get(0);  
> List\<CompletionSuggestion.Entry.Option\> options  
> =entry.getOptions();  
> if(options != null) {  
> CompletionSuggestion.Entry.Option option = options.get(0);  
> toReturn = option.getText().string();  
> }  
> }  
> return toReturn;
> 
> I've made progress! But now it's falling apart when I try parsing the  
> entries from the suggestReponse. So, am I doing this correctly? Missing  
> something?
> 
> Thanks!
> 
> > 
> 
> On Monday, April 7, 2014 6:26:37 AM UTC-4, Dan wrote:
> 
> > Use the SuggestRequestBuilder, i.e.
> > 
> > CompletionSuggestionBuilder compBuilder = new  
> > CompletionSuggestionBuilder("complete");  
> > compBuilder.text("n");  
> > compBuilder.field("suggest");
> > 
> > SuggestRequestBuilder suggestRequestBuilder =  
> > client.prepareSuggest(INDEX\_NAME);  
> > suggestRequestBuilder.addSuggestion(compBuilder);  
> > SuggestResponse suggestResponse =  
> > suggestRequestBuilder.execute().actionGet();
> > 
> > Dan
> > 
> > On Mon, Apr 7, 2014 at 8:49 AM, Alexander Reelsen [a...@spinscale.de](mailto:a...@spinscale.de)wrote:
> > 
> > > Hey,
> > > 
> > > looks ok. Minor note: Types are simply ignored for suggestions. What are  
> > > you getting back? Nothing?  
> > > Can you create a fully working gist, including creation of the mapping  
> > > and indexing? Then debugging and finding your possible cause would be a lot  
> > > easier.
> > > 
> > > --Alex
> > > 
> > > On Fri, Apr 4, 2014 at 4:02 PM, Bill Wortinger [r3dr...@gmail.com](mailto:r3dr...@gmail.com)wrote:
> > > 
> > > > I have my indices created, and mapping type for my 'suggest' field set  
> > > > to completion. I can't figure out how to configure the query for completion  
> > > > suggestions in elastic-search (Java API).
> > > > 
> > > > I'm trying to use this Query to base my implementation off of. "song-suggest" : { "text" : "n", "completion" : { "field" : "suggest" } } Here's  
> > > > what I have so far,
> > > > 
> > > > ```
> > > > CompletionSuggestionBuilder compBuilder = new CompletionSuggestionBuilder("complete"); 
> > > > compBuilder.text("n..");
> > > > compBuilder.field("suggest");
> > > > 
> > > > SearchResponse searchResponse = localClient.prepareSearch(INDEX_NAME)
> > > > .setTypes("completion")
> > > > .setQuery(QueryBuilders.matchAllQuery())
> > > > .addSuggestion(compBuilder)
> > > > .execute().actionGet();
> > > > 
> > > > CompletionSuggestion compSuggestion = searchResponse.getSuggest().getSuggestion("complete");
> > > > 
> > > > ```
> > > > 
> > > > Am I missing something, doing something wrong? Thanks!
> > > > 
> > > > --  
> > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit  
> > > > [https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%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/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Bill\_Wortinger](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Bill\_Wortinger](https://discuss.elastic.co/u/Bill_Wortinger)\
**Post date:** [April 8, 2014, 3:07pm UTC](https://discuss.elastic.co/t/querying-with-completion-suggesters-with-java-api/16822/7 "2014-04-08T15:07:57Z")

</div>

Great resource! Thank you,

_CompletionSuggestionBuilder compBuilder = new  
CompletionSuggestionBuilder("completion");  
compBuilder.text(suggestion); compBuilder.field("suggest");  
SuggestRequestBuilder suggestRequestBuilder =  
localClient.prepareSuggest(INDEX\_NAME)  
.addSuggestion(compBuilder); SuggestResponse suggestResponse  
= suggestRequestBuilder.execute().actionGet();_

When executing

_Suggest.Suggestion.Entry.Option option2 =  
suggestResponse.getSuggest().getSuggestion("completion").getEntries().get(0).getOptions().get(0);_  
A null is returned.

Below is my index.

_.startObject("suggest").field("type", "completion").endObject()_

Thanks again!

On Tue, Apr 8, 2014 at 9:14 AM, Dan [dan.tuffery@gmail.com](mailto:dan.tuffery@gmail.com) wrote:

> What is the issue you're seeing? Have a look at the examples in the tests:
> 
> [https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchTests.java](https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchTests.java)
> 
> Dan
> 
> On Tuesday, April 8, 2014 1:43:29 PM UTC+1, Bill Wortinger wrote:
> 
> > Thanks for the heads up Alex, I'll remove the .setTypes().
> > 
> > Dan, this is what I have so far;
> > 
> > CompletionSuggestionBuilder compBuilder = new  
> > CompletionSuggestionBuilder("complete");  
> > compBuilder.text('n");  
> > compBuilder.field("suggest");  
> > SuggestRequestBuilder suggestRequestBuilder = client.prepareSuggest(INDEX\_  
> > NAME);  
> > suggestRequestBuilder.addSuggestion(compBuilder);  
> > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > ).actionGet();
> > 
> > CompletionSuggestion compSuggestion = suggestResponse.getSuggest().  
> > getSuggestion("complete");
> > 
> > List\<CompletionSuggestion.Entry\> entryList = compSuggestion.getEntries();  
> > if(entryList != null) {  
> > CompletionSuggestion.Entry entry = entryList.get(0);  
> > List\<CompletionSuggestion.Entry.Option\> options  
> > =entry.getOptions();  
> > if(options != null) {  
> > CompletionSuggestion.Entry.Option option =  
> > options.get(0);  
> > toReturn = option.getText().string();  
> > }  
> > }  
> > return toReturn;
> > 
> > I've made progress! But now it's falling apart when I try parsing the  
> > entries from the suggestReponse. So, am I doing this correctly? Missing  
> > something?
> > 
> > Thanks!
> > 
> > > 
> > 
> > On Monday, April 7, 2014 6:26:37 AM UTC-4, Dan wrote:
> > 
> > > Use the SuggestRequestBuilder, i.e.
> > > 
> > > CompletionSuggestionBuilder compBuilder = new  
> > > CompletionSuggestionBuilder("complete");  
> > > compBuilder.text("n");  
> > > compBuilder.field("suggest");
> > > 
> > > SuggestRequestBuilder suggestRequestBuilder =  
> > > client.prepareSuggest(INDEX\_NAME);  
> > > suggestRequestBuilder.addSuggestion(compBuilder);  
> > > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > > ).actionGet();
> > > 
> > > Dan
> > > 
> > > On Mon, Apr 7, 2014 at 8:49 AM, Alexander Reelsen [a...@spinscale.de](mailto:a...@spinscale.de)wrote:
> > > 
> > > > Hey,
> > > > 
> > > > looks ok. Minor note: Types are simply ignored for suggestions. What  
> > > > are you getting back? Nothing?  
> > > > Can you create a fully working gist, including creation of the mapping  
> > > > and indexing? Then debugging and finding your possible cause would be a lot  
> > > > easier.
> > > > 
> > > > --Alex
> > > > 
> > > > On Fri, Apr 4, 2014 at 4:02 PM, Bill Wortinger [r3dr...@gmail.com](mailto:r3dr...@gmail.com)wrote:
> > > > 
> > > > > I have my indices created, and mapping type for my 'suggest' field set  
> > > > > to completion. I can't figure out how to configure the query for completion  
> > > > > suggestions in elastic-search (Java API).
> > > > > 
> > > > > I'm trying to use this Query to base my implementation off of. "song-suggest" : { "text" : "n", "completion" : { "field" : "suggest" } } Here's  
> > > > > what I have so far,
> > > > > 
> > > > > ```
> > > > > CompletionSuggestionBuilder compBuilder = new CompletionSuggestionBuilder("complete");
> > > > > compBuilder.text("n..");
> > > > > compBuilder.field("suggest");
> > > > > 
> > > > > SearchResponse searchResponse = localClient.prepareSearch(INDEX_NAME)
> > > > > .setTypes("completion")
> > > > > .setQuery(QueryBuilders.matchAllQuery())
> > > > > .addSuggestion(compBuilder)
> > > > > .execute().actionGet();
> > > > > 
> > > > > CompletionSuggestion compSuggestion = searchResponse.getSuggest().getSuggestion("complete");
> > > > > 
> > > > > ```
> > > > > 
> > > > > Am I missing something, doing something wrong? Thanks!
> > > > > 
> > > > > --  
> > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%  
> > > > > [40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%  
> > > > 3DyXd0uMdTVpSUBvg%[40mail.gmail.com](http://40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%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 a topic in the  
> > > Google Groups "elasticsearch" group.  
> > > To unsubscribe from this topic, visit  
> > > [https://groups.google.com/d/topic/elasticsearch/06nbxJnYfDo/unsubscribe](https://groups.google.com/d/topic/elasticsearch/06nbxJnYfDo/unsubscribe).  
> > > To unsubscribe from this group and all its topics, 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/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.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/CAJ%3D6wEcBteL0B4Z5L9yuVzz6DK2WM-YJt7q7%2B6XtkcFBNabnGg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAJ%3D6wEcBteL0B4Z5L9yuVzz6DK2WM-YJt7q7%2B6XtkcFBNabnGg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [April 9, 2014, 7:56am UTC](https://discuss.elastic.co/t/querying-with-completion-suggesters-with-java-api/16822/8 "2014-04-09T07:56:37Z")

</div>

This looks wrong,

_Suggest.Suggestion.Entry.Option option2 =  
suggestResponse.getSuggest().getSuggestion("completion").getEntries().get(0).getOptions().get(0);_

it should be:

\*Suggest.Suggestion.Entry.Option option2 = \*  
_suggestResponse.getSuggest().getSuggestion("suggest").getEntries().get(0).getOptions().get(0);_

Where _getSuggestion_ is getting the field name you supplied in the request.

Dan

So it looks like your query is returning zero results. Can you see values  
indexed for the field 'at'

On Tuesday, April 8, 2014 4:07:57 PM UTC+1, Bill Wortinger wrote:

> Great resource! Thank you,
> 
> _CompletionSuggestionBuilder compBuilder = new  
> CompletionSuggestionBuilder("completion");  
> compBuilder.text(suggestion); compBuilder.field("suggest");  
> SuggestRequestBuilder suggestRequestBuilder =  
> localClient.prepareSuggest(INDEX\_NAME)  
> .addSuggestion(compBuilder); SuggestResponse suggestResponse  
> = suggestRequestBuilder.execute().actionGet();_
> 
> When executing
> 
> _Suggest.Suggestion.Entry.Option option2 =  
> suggestResponse.getSuggest().getSuggestion("completion").getEntries().get(0).getOptions().get(0);_  
> A null is returned.
> 
> Below is my index.
> 
> _.startObject("suggest").field("type", "completion").endObject()_
> 
> Thanks again!
> 
> On Tue, Apr 8, 2014 at 9:14 AM, Dan \<[dan.t...@gmail.com](mailto:dan.t...@gmail.com) \<javascript:\>\>wrote:
> 
> > What is the issue you're seeing? Have a look at the examples in the tests:
> > 
> > [https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchTests.java](https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchTests.java)
> > 
> > Dan
> > 
> > On Tuesday, April 8, 2014 1:43:29 PM UTC+1, Bill Wortinger wrote:
> > 
> > > Thanks for the heads up Alex, I'll remove the .setTypes().
> > > 
> > > Dan, this is what I have so far;
> > > 
> > > CompletionSuggestionBuilder compBuilder = new  
> > > CompletionSuggestionBuilder("complete");  
> > > compBuilder.text('n");  
> > > compBuilder.field("suggest");  
> > > SuggestRequestBuilder suggestRequestBuilder =  
> > > client.prepareSuggest(INDEX\_NAME);  
> > > suggestRequestBuilder.addSuggestion(compBuilder);  
> > > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > > ).actionGet();
> > > 
> > > CompletionSuggestion compSuggestion = suggestResponse.getSuggest().  
> > > getSuggestion("complete");
> > > 
> > > List\<CompletionSuggestion.Entry\> entryList =  
> > > compSuggestion.getEntries();  
> > > if(entryList != null) {  
> > > CompletionSuggestion.Entry entry = entryList.get(0);  
> > > List\<CompletionSuggestion.Entry.Option\> options  
> > > =entry.getOptions();  
> > > if(options != null) {  
> > > CompletionSuggestion.Entry.Option option =  
> > > options.get(0);  
> > > toReturn = option.getText().string();  
> > > }  
> > > }  
> > > return toReturn;
> > > 
> > > I've made progress! But now it's falling apart when I try parsing the  
> > > entries from the suggestReponse. So, am I doing this correctly? Missing  
> > > something?
> > > 
> > > Thanks!
> > > 
> > > > 
> > > 
> > > On Monday, April 7, 2014 6:26:37 AM UTC-4, Dan wrote:
> > > 
> > > > Use the SuggestRequestBuilder, i.e.
> > > > 
> > > > CompletionSuggestionBuilder compBuilder = new  
> > > > CompletionSuggestionBuilder("complete");  
> > > > compBuilder.text("n");  
> > > > compBuilder.field("suggest");
> > > > 
> > > > SuggestRequestBuilder suggestRequestBuilder =  
> > > > client.prepareSuggest(INDEX\_NAME);  
> > > > suggestRequestBuilder.addSuggestion(compBuilder);  
> > > > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > > > ).actionGet();
> > > > 
> > > > Dan
> > > > 
> > > > On Mon, Apr 7, 2014 at 8:49 AM, Alexander Reelsen [a...@spinscale.de](mailto:a...@spinscale.de)wrote:
> > > > 
> > > > > Hey,
> > > > > 
> > > > > looks ok. Minor note: Types are simply ignored for suggestions. What  
> > > > > are you getting back? Nothing?  
> > > > > Can you create a fully working gist, including creation of the mapping  
> > > > > and indexing? Then debugging and finding your possible cause would be a lot  
> > > > > easier.
> > > > > 
> > > > > --Alex
> > > > > 
> > > > > On Fri, Apr 4, 2014 at 4:02 PM, Bill Wortinger [r3dr...@gmail.com](mailto:r3dr...@gmail.com)wrote:
> > > > > 
> > > > > > I have my indices created, and mapping type for my 'suggest' field  
> > > > > > set to completion. I can't figure out how to configure the query for  
> > > > > > completion suggestions in elastic-search (Java API).
> > > > > > 
> > > > > > I'm trying to use this Query to base my implementation off of. "song-suggest" : { "text" : "n", "completion" : { "field" : "suggest" } } Here's  
> > > > > > what I have so far,
> > > > > > 
> > > > > > ```
> > > > > > CompletionSuggestionBuilder compBuilder = new CompletionSuggestionBuilder("complete"); 
> > > > > > compBuilder.text("n..");
> > > > > > compBuilder.field("suggest");
> > > > > > 
> > > > > > SearchResponse searchResponse = localClient.prepareSearch(INDEX_NAME)
> > > > > > .setTypes("completion")
> > > > > > .setQuery(QueryBuilders.matchAllQuery())
> > > > > > .addSuggestion(compBuilder)
> > > > > > .execute().actionGet();
> > > > > > 
> > > > > > CompletionSuggestion compSuggestion = searchResponse.getSuggest().getSuggestion("complete");
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > Am I missing something, doing something wrong? Thanks!
> > > > > > 
> > > > > > --  
> > > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > > msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%  
> > > > > > [40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%  
> > > > > 3DyXd0uMdTVpSUBvg%[40mail.gmail.com](http://40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%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 a topic in the  
> > > > Google Groups "elasticsearch" group.  
> > > > To unsubscribe from this topic, visit  
> > > > [https://groups.google.com/d/topic/elasticsearch/06nbxJnYfDo/unsubscribe](https://groups.google.com/d/topic/elasticsearch/06nbxJnYfDo/unsubscribe).  
> > > > To unsubscribe from this group and all its topics, send an email to  
> > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > > To view this discussion on the web visit  
> > > > [https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.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/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Bill\_Wortinger](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Bill\_Wortinger](https://discuss.elastic.co/u/Bill_Wortinger)\
**Post date:** [April 10, 2014, 1:50pm UTC](https://discuss.elastic.co/t/querying-with-completion-suggesters-with-java-api/16822/9 "2014-04-10T13:50:05Z")

</div>

Hello Dan, thanks again for all the help but I can't seem to get anything  
to return. Here is my full code, there has to be something I'm missing.  
Maybe in the indexing, the mapping?

Mapping:  
putMappingResponse = new PutMappingRequestBuilder(newClient  
.admin().indices())  
.setIndices(INDEX\_NAME)  
.setType(INDEX\_TYPE)  
.setSource(jsonBuilder().startObject("suggest")  
.field("type", "completion")  
.endObject().execute().actionGet());

Method:  
public String searchSuggestions(String suggestion) {  
// Creates suggestions based on Document Titles.  
String toReturn = "";

Client localClient = getElasticSearchClient();

CompletionSuggestionBuilder compBuilder = new  
CompletionSuggestionBuilder("completion");  
compBuilder.text(suggestion);  
compBuilder.field("suggest");

SuggestRequestBuilder suggestRequestBuilder = localClient  
.prepareSuggest(INDEX\_NAME).addSuggestion(compBuilder);

SuggestResponse suggestResponse =  
suggestRequestBuilder.execute().actionGet();  
CompletionSuggestion compSuggestion =  
suggestResponse.getSuggest().getSuggestion("completion");

List\<CompletionSuggestion.Entry\> entryList = compSuggestion.getEntries();  
if (entryList != null) {  
CompletionSuggestion.Entry entry = entryList.get(0);  
List\<CompletionSuggestion.Entry.Option\> options = entry.getOptions();  
if (options != null) {  
CompletionSuggestion.Entry.Option option = options.get(0);  
toReturn = option.getText().string();  
}  
}  
return toReturn;  
}

Index:  
response = localClient.prepareIndex(INDEX\_NAME, INDEX\_TYPE)  
.setSource(jsonBuilder().startObject("suggest").field("input","FooFighters").endObject()).execute().actionGet();

Thanks for all the help, I'm basically shooting in the dark hoping somebody  
with more experience can spot the issue.

On Wed, Apr 9, 2014 at 3:56 AM, Dan Tuffery [dan.tuffery@gmail.com](mailto:dan.tuffery@gmail.com) wrote:

> This looks wrong,
> 
> _Suggest.Suggestion.Entry.Option option2 =  
> suggestResponse.getSuggest().getSuggestion("completion").getEntries().get(0).getOptions().get(0);_
> 
> it should be:
> 
> \*Suggest.Suggestion.Entry.Option option2 = \*  
> _suggestResponse.getSuggest().getSuggestion("suggest").getEntries().get(0).getOptions().get(0);_
> 
> Where _getSuggestion_ is getting the field name you supplied in the  
> request.
> 
> Dan
> 
> So it looks like your query is returning zero results. Can you see values  
> indexed for the field 'at'
> 
> On Tuesday, April 8, 2014 4:07:57 PM UTC+1, Bill Wortinger wrote:
> 
> > Great resource! Thank you,
> > 
> > _CompletionSuggestionBuilder compBuilder = new  
> > CompletionSuggestionBuilder("completion");  
> > compBuilder.text(suggestion); compBuilder.field("suggest");  
> > SuggestRequestBuilder suggestRequestBuilder =  
> > localClient.prepareSuggest(INDEX\_NAME)  
> > .addSuggestion(compBuilder); SuggestResponse suggestResponse  
> > = suggestRequestBuilder.execute().actionGet();_
> > 
> > When executing
> > 
> > _Suggest.Suggestion.Entry.Option option2 =  
> > suggestResponse.getSuggest().getSuggestion("completion").getEntries().get(0).getOptions().get(0);_  
> > A null is returned.
> > 
> > Below is my index.
> > 
> > _.startObject("suggest").field("type", "completion").endObject()_
> > 
> > Thanks again!
> > 
> > On Tue, Apr 8, 2014 at 9:14 AM, Dan [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > 
> > > What is the issue you're seeing? Have a look at the examples in the  
> > > tests:
> > > 
> > > [GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine](https://github.com/elasticsearch/elasticsearch/)  
> > > blob/master/src/test/java/org/elasticsearch/search/suggest/  
> > > CompletionSuggestSearchTests.java
> > > 
> > > Dan
> > > 
> > > On Tuesday, April 8, 2014 1:43:29 PM UTC+1, Bill Wortinger wrote:
> > > 
> > > > Thanks for the heads up Alex, I'll remove the .setTypes().
> > > > 
> > > > Dan, this is what I have so far;
> > > > 
> > > > CompletionSuggestionBuilder compBuilder = new  
> > > > CompletionSuggestionBuilder("complete");  
> > > > compBuilder.text('n");  
> > > > compBuilder.field("suggest");  
> > > > SuggestRequestBuilder suggestRequestBuilder =  
> > > > client.prepareSuggest(INDEX\_NAME);  
> > > > suggestRequestBuilder.addSuggestion(compBuilder);  
> > > > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > > > ).actionGet();
> > > > 
> > > > CompletionSuggestion compSuggestion = suggestResponse.getSuggest().g  
> > > > etSuggestion("complete");
> > > > 
> > > > List\<CompletionSuggestion.Entry\> entryList =  
> > > > compSuggestion.getEntries();  
> > > > if(entryList != null) {  
> > > > CompletionSuggestion.Entry entry = entryList.get(0);  
> > > > List\<CompletionSuggestion.Entry.Option\> options  
> > > > =entry.getOptions();  
> > > > if(options != null) {  
> > > > CompletionSuggestion.Entry.Option option =  
> > > > options.get(0);  
> > > > toReturn = option.getText().string();  
> > > > }  
> > > > }  
> > > > return toReturn;
> > > > 
> > > > I've made progress! But now it's falling apart when I try parsing the  
> > > > entries from the suggestReponse. So, am I doing this correctly? Missing  
> > > > something?
> > > > 
> > > > Thanks!
> > > > 
> > > > > 
> > > > 
> > > > On Monday, April 7, 2014 6:26:37 AM UTC-4, Dan wrote:
> > > > 
> > > > > Use the SuggestRequestBuilder, i.e.
> > > > > 
> > > > > CompletionSuggestionBuilder compBuilder = new  
> > > > > CompletionSuggestionBuilder("complete");  
> > > > > compBuilder.text("n");  
> > > > > compBuilder.field("suggest");
> > > > > 
> > > > > SuggestRequestBuilder suggestRequestBuilder =  
> > > > > client.prepareSuggest(INDEX\_NAME);  
> > > > > suggestRequestBuilder.addSuggestion(compBuilder);  
> > > > > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > > > > ).actionGet();
> > > > > 
> > > > > Dan
> > > > > 
> > > > > On Mon, Apr 7, 2014 at 8:49 AM, Alexander Reelsen [a...@spinscale.de](mailto:a...@spinscale.de)wrote:
> > > > > 
> > > > > > Hey,
> > > > > > 
> > > > > > looks ok. Minor note: Types are simply ignored for suggestions. What  
> > > > > > are you getting back? Nothing?  
> > > > > > Can you create a fully working gist, including creation of the  
> > > > > > mapping and indexing? Then debugging and finding your possible cause would  
> > > > > > be a lot easier.
> > > > > > 
> > > > > > --Alex
> > > > > > 
> > > > > > On Fri, Apr 4, 2014 at 4:02 PM, Bill Wortinger [r3dr...@gmail.com](mailto:r3dr...@gmail.com)wrote:
> > > > > > 
> > > > > > > I have my indices created, and mapping type for my 'suggest' field  
> > > > > > > set to completion. I can't figure out how to configure the query for  
> > > > > > > completion suggestions in elastic-search (Java API).
> > > > > > > 
> > > > > > > I'm trying to use this Query to base my implementation off of. "song-suggest" : { "text" : "n", "completion" : { "field" : "suggest" } } Here's  
> > > > > > > what I have so far,
> > > > > > > 
> > > > > > > ```
> > > > > > > CompletionSuggestionBuilder compBuilder = new CompletionSuggestionBuilder("complete");
> > > > > > > compBuilder.text("n..");
> > > > > > > compBuilder.field("suggest");
> > > > > > > 
> > > > > > > SearchResponse searchResponse = localClient.prepareSearch(INDEX_NAME)
> > > > > > > .setTypes("completion")
> > > > > > > .setQuery(QueryBuilders.matchAllQuery())
> > > > > > > .addSuggestion(compBuilder)
> > > > > > > .execute().actionGet();
> > > > > > > 
> > > > > > > CompletionSuggestion compSuggestion = searchResponse.getSuggest().getSuggestion("complete");
> > > > > > > 
> > > > > > > ```
> > > > > > > 
> > > > > > > Am I missing something, doing something wrong? Thanks!
> > > > > > > 
> > > > > > > --  
> > > > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > > To view this discussion on the web visit  
> > > > > > > [https://groups.google.com/d/msgid/elasticsearch/06792c37-646](https://groups.google.com/d/msgid/elasticsearch/06792c37-646)  
> > > > > > > c-4b59-bdb3-f23cc51bd134%[40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > > msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyX  
> > > > > > d0uMdTVpSUBvg%[40mail.gmail.com](http://40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%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 a topic in the  
> > > > > Google Groups "elasticsearch" group.  
> > > > > To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > topic/elasticsearch/06nbxJnYfDo/unsubscribe.  
> > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%  
> > > > > [40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.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 a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/06nbxJnYfDo/unsubscribe](https://groups.google.com/d/topic/elasticsearch/06nbxJnYfDo/unsubscribe).  
> > To unsubscribe from this group and all its topics, 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/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.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/CAJ%3D6wEdQVBqfTkvC3rzDs6wUWxV7KW7MA-NgEq14RdF7O500jg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAJ%3D6wEdQVBqfTkvC3rzDs6wUWxV7KW7MA-NgEq14RdF7O500jg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [April 11, 2014, 5:11am UTC](https://discuss.elastic.co/t/querying-with-completion-suggesters-with-java-api/16822/10 "2014-04-11T05:11:41Z")

</div>

I did a quick test, this works:

_Create mapping_

curl -XPUT '[http://localhost:9200/example/test/\_mapping](http://localhost:9200/example/test/_mapping)' -d  
'{  
"test": {  
"properties": {  
"my\_suggest": {  
"type": "completion"  
}  
}  
}  
}'

_Index value_

curl -XPUT '[http://localhost:9200/example/test/1/](http://localhost:9200/example/test/1/)' -d  
'{  
"my\_suggest": "FooFighters"  
}'

_Java API code_

CompletionSuggestionBuilder compBuilder = new  
CompletionSuggestionBuilder("my\_suggest");  
compBuilder.text("Foo");  
compBuilder.field("my\_suggest");

SuggestRequestBuilder suggestRequestBuilder = client  
.prepareSuggest("example").addSuggestion(compBuilder);

SuggestResponse suggestResponse =  
suggestRequestBuilder.execute().actionGet();  
CompletionSuggestion compSuggestion =  
suggestResponse.getSuggest().getSuggestion("my\_suggest");

List\<CompletionSuggestion.Entry\> entryList = compSuggestion.getEntries();  
if (entryList != null) {  
CompletionSuggestion.Entry entry = entryList.get(0);  
List\<CompletionSuggestion.Entry.Option\> options = entry.getOptions();  
if (options != null) {  
CompletionSuggestion.Entry.Option option = options.get(0);  
//the value of toReturn is 'FooFighters'  
String toReturn = option.getText().string()  
}

Dan

On Thursday, April 10, 2014 2:50:05 PM UTC+1, Bill Wortinger wrote:

> Hello Dan, thanks again for all the help but I can't seem to get anything  
> to return. Here is my full code, there has to be something I'm missing.  
> Maybe in the indexing, the mapping?
> 
> Mapping:  
> putMappingResponse = new PutMappingRequestBuilder(newClient  
> .admin().indices())  
> .setIndices(INDEX\_NAME)  
> .setType(INDEX\_TYPE)  
> .setSource(jsonBuilder().startObject("suggest")  
> .field("type", "completion")  
> .endObject().execute().actionGet());
> 
> Method:  
> public String searchSuggestions(String suggestion) {  
> // Creates suggestions based on Document Titles.  
> String toReturn = "";
> 
> Client localClient = getElasticSearchClient();
> 
> CompletionSuggestionBuilder compBuilder = new  
> CompletionSuggestionBuilder("completion");  
> compBuilder.text(suggestion);  
> compBuilder.field("suggest");
> 
> SuggestRequestBuilder suggestRequestBuilder = localClient  
> .prepareSuggest(INDEX\_NAME).addSuggestion(compBuilder);
> 
> SuggestResponse suggestResponse =  
> suggestRequestBuilder.execute().actionGet();  
> CompletionSuggestion compSuggestion =  
> suggestResponse.getSuggest().getSuggestion("completion");
> 
> List\<CompletionSuggestion.Entry\> entryList = compSuggestion.getEntries();  
> if (entryList != null) {  
> CompletionSuggestion.Entry entry = entryList.get(0);  
> List\<CompletionSuggestion.Entry.Option\> options = entry.getOptions();  
> if (options != null) {  
> CompletionSuggestion.Entry.Option option = options.get(0);  
> toReturn = option.getText().string();  
> }  
> }  
> return toReturn;  
> }
> 
> Index:  
> response = localClient.prepareIndex(INDEX\_NAME, INDEX\_TYPE)
> 
> .setSource(jsonBuilder().startObject("suggest").field("input","FooFighters").endObject()).execute().actionGet();
> 
> Thanks for all the help, I'm basically shooting in the dark hoping  
> somebody with more experience can spot the issue.
> 
> On Wed, Apr 9, 2014 at 3:56 AM, Dan Tuffery \<[dan.t...@gmail.com](mailto:dan.t...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > This looks wrong,
> > 
> > _Suggest.Suggestion.Entry.Option option2 =  
> > suggestResponse.getSuggest().getSuggestion("completion").getEntries().get(0).getOptions().get(0);_
> > 
> > it should be:
> > 
> > \*Suggest.Suggestion.Entry.Option option2 = \*  
> > _suggestResponse.getSuggest().getSuggestion("suggest").getEntries().get(0).getOptions().get(0);_
> > 
> > Where _getSuggestion_ is getting the field name you supplied in the  
> > request.
> > 
> > Dan
> > 
> > So it looks like your query is returning zero results. Can you see values  
> > indexed for the field 'at'
> > 
> > On Tuesday, April 8, 2014 4:07:57 PM UTC+1, Bill Wortinger wrote:
> > 
> > > Great resource! Thank you,
> > > 
> > > _CompletionSuggestionBuilder compBuilder = new  
> > > CompletionSuggestionBuilder("completion");  
> > > compBuilder.text(suggestion); compBuilder.field("suggest");  
> > > SuggestRequestBuilder suggestRequestBuilder =  
> > > localClient.prepareSuggest(INDEX\_NAME)  
> > > .addSuggestion(compBuilder); SuggestResponse suggestResponse  
> > > = suggestRequestBuilder.execute().actionGet();_
> > > 
> > > When executing
> > > 
> > > _Suggest.Suggestion.Entry.Option option2 =  
> > > suggestResponse.getSuggest().getSuggestion("completion").getEntries().get(0).getOptions().get(0);_  
> > > A null is returned.
> > > 
> > > Below is my index.
> > > 
> > > _.startObject("suggest").field("type", "completion").endObject()_
> > > 
> > > Thanks again!
> > > 
> > > On Tue, Apr 8, 2014 at 9:14 AM, Dan [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > 
> > > > What is the issue you're seeing? Have a look at the examples in the  
> > > > tests:
> > > > 
> > > > [GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine](https://github.com/elasticsearch/elasticsearch/)  
> > > > blob/master/src/test/java/org/elasticsearch/search/suggest/  
> > > > CompletionSuggestSearchTests.java
> > > > 
> > > > Dan
> > > > 
> > > > On Tuesday, April 8, 2014 1:43:29 PM UTC+1, Bill Wortinger wrote:
> > > > 
> > > > > Thanks for the heads up Alex, I'll remove the .setTypes().
> > > > > 
> > > > > Dan, this is what I have so far;
> > > > > 
> > > > > CompletionSuggestionBuilder compBuilder = new  
> > > > > CompletionSuggestionBuilder("complete");  
> > > > > compBuilder.text('n");  
> > > > > compBuilder.field("suggest");  
> > > > > SuggestRequestBuilder suggestRequestBuilder =  
> > > > > client.prepareSuggest(INDEX\_NAME);  
> > > > > suggestRequestBuilder.addSuggestion(compBuilder);  
> > > > > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > > > > ).actionGet();
> > > > > 
> > > > > CompletionSuggestion compSuggestion = suggestResponse.getSuggest().g  
> > > > > etSuggestion("complete");
> > > > > 
> > > > > List\<CompletionSuggestion.Entry\> entryList =  
> > > > > compSuggestion.getEntries();  
> > > > > if(entryList != null) {  
> > > > > CompletionSuggestion.Entry entry = entryList.get(0);  
> > > > > List\<CompletionSuggestion.Entry.Option\> options  
> > > > > =entry.getOptions();  
> > > > > if(options != null) {  
> > > > > CompletionSuggestion.Entry.Option option =  
> > > > > options.get(0);  
> > > > > toReturn = option.getText().string();  
> > > > > }  
> > > > > }  
> > > > > return toReturn;
> > > > > 
> > > > > I've made progress! But now it's falling apart when I try parsing the  
> > > > > entries from the suggestReponse. So, am I doing this correctly? Missing  
> > > > > something?
> > > > > 
> > > > > Thanks!
> > > > > 
> > > > > > 
> > > > > 
> > > > > On Monday, April 7, 2014 6:26:37 AM UTC-4, Dan wrote:
> > > > > 
> > > > > > Use the SuggestRequestBuilder, i.e.
> > > > > > 
> > > > > > CompletionSuggestionBuilder compBuilder = new  
> > > > > > CompletionSuggestionBuilder("complete");  
> > > > > > compBuilder.text("n");  
> > > > > > compBuilder.field("suggest");
> > > > > > 
> > > > > > SuggestRequestBuilder suggestRequestBuilder =  
> > > > > > client.prepareSuggest(INDEX\_NAME);  
> > > > > > suggestRequestBuilder.addSuggestion(compBuilder);  
> > > > > > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > > > > > ).actionGet();
> > > > > > 
> > > > > > Dan
> > > > > > 
> > > > > > On Mon, Apr 7, 2014 at 8:49 AM, Alexander Reelsen [a...@spinscale.de](mailto:a...@spinscale.de)wrote:
> > > > > > 
> > > > > > > Hey,
> > > > > > > 
> > > > > > > looks ok. Minor note: Types are simply ignored for suggestions. What  
> > > > > > > are you getting back? Nothing?  
> > > > > > > Can you create a fully working gist, including creation of the  
> > > > > > > mapping and indexing? Then debugging and finding your possible cause would  
> > > > > > > be a lot easier.
> > > > > > > 
> > > > > > > --Alex
> > > > > > > 
> > > > > > > On Fri, Apr 4, 2014 at 4:02 PM, Bill Wortinger [r3dr...@gmail.com](mailto:r3dr...@gmail.com)wrote:
> > > > > > > 
> > > > > > > > I have my indices created, and mapping type for my 'suggest' field  
> > > > > > > > set to completion. I can't figure out how to configure the query for  
> > > > > > > > completion suggestions in elastic-search (Java API).
> > > > > > > > 
> > > > > > > > I'm trying to use this Query to base my implementation off of. "song-suggest" : { "text" : "n", "completion" : { "field" : "suggest" } } Here's  
> > > > > > > > what I have so far,
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > CompletionSuggestionBuilder compBuilder = new CompletionSuggestionBuilder("complete"); 
> > > > > > > > compBuilder.text("n..");
> > > > > > > > compBuilder.field("suggest");
> > > > > > > > 
> > > > > > > > SearchResponse searchResponse = localClient.prepareSearch(INDEX_NAME)
> > > > > > > > .setTypes("completion")
> > > > > > > > .setQuery(QueryBuilders.matchAllQuery())
> > > > > > > > .addSuggestion(compBuilder)
> > > > > > > > .execute().actionGet();
> > > > > > > > 
> > > > > > > > CompletionSuggestion compSuggestion = searchResponse.getSuggest().getSuggestion("complete");
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > 
> > > > > > > > Am I missing something, doing something wrong? Thanks!
> > > > > > > > 
> > > > > > > > --  
> > > > > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > > > To view this discussion on the web visit  
> > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/06792c37-646](https://groups.google.com/d/msgid/elasticsearch/06792c37-646)  
> > > > > > > > c-4b59-bdb3-f23cc51bd134%[40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > > To view this discussion on the web visit  
> > > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76G](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76G)  
> > > > > > > mrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%[40mail.gmail.com](http://40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%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 a topic in the  
> > > > > > Google Groups "elasticsearch" group.  
> > > > > > To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > > topic/elasticsearch/06nbxJnYfDo/unsubscribe.  
> > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > > msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%  
> > > > > > [40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.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 a topic in the  
> > > Google Groups "elasticsearch" group.  
> > > To unsubscribe from this topic, visit  
> > > [https://groups.google.com/d/topic/elasticsearch/06nbxJnYfDo/unsubscribe](https://groups.google.com/d/topic/elasticsearch/06nbxJnYfDo/unsubscribe).  
> > > To unsubscribe from this group and all its topics, send an email to  
> > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.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/3e73ca3a-9f27-417a-b097-846dfa4730d0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3e73ca3a-9f27-417a-b097-846dfa4730d0%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Bill\_Wortinger](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Bill\_Wortinger](https://discuss.elastic.co/u/Bill_Wortinger)\
**Post date:** [April 15, 2014, 1:31pm UTC](https://discuss.elastic.co/t/querying-with-completion-suggesters-with-java-api/16822/11 "2014-04-15T13:31:01Z")

</div>

Hey Dan!

Thanks for the code snippet, it's actually helped me narrow down my problem  
considerably. I'm getting the error;

field 'suggest' is not a completion suggest field.

To my knowledge, you define it as a completion suggest field with the type  
in the mapping.

.field("suggest").startObject().field("type", "completion").endObject()

Thanks!

On Fri, Apr 11, 2014 at 1:11 AM, Dan Tuffery [dan.tuffery@gmail.com](mailto:dan.tuffery@gmail.com) wrote:

> I did a quick test, this works:
> 
> _Create mapping_
> 
> curl -XPUT '[http://localhost:9200/example/test/\_mapping](http://localhost:9200/example/test/_mapping)' -d  
> '{  
> "test": {  
> "properties": {  
> "my\_suggest": {  
> "type": "completion"  
> }  
> }  
> }  
> }'
> 
> _Index value_
> 
> curl -XPUT '[http://localhost:9200/example/test/1/](http://localhost:9200/example/test/1/)' -d  
> '{  
> "my\_suggest": "FooFighters"  
> }'
> 
> _Java API code_
> 
> CompletionSuggestionBuilder compBuilder = new  
> CompletionSuggestionBuilder("my\_suggest");  
> compBuilder.text("Foo");  
> compBuilder.field("my\_suggest");
> 
> SuggestRequestBuilder suggestRequestBuilder = client  
> .prepareSuggest("example").addSuggestion(compBuilder);
> 
> SuggestResponse suggestResponse =  
> suggestRequestBuilder.execute().actionGet();  
> CompletionSuggestion compSuggestion =  
> suggestResponse.getSuggest().getSuggestion("my\_suggest");
> 
> List\<CompletionSuggestion.Entry\> entryList = compSuggestion.getEntries();  
> if (entryList != null) {  
> CompletionSuggestion.Entry entry = entryList.get(0);  
> List\<CompletionSuggestion.Entry.Option\> options = entry.getOptions();  
> if (options != null) {  
> CompletionSuggestion.Entry.Option option = options.get(0);  
> //the value of toReturn is 'FooFighters'  
> String toReturn = option.getText().string()  
> }
> 
> Dan
> 
> On Thursday, April 10, 2014 2:50:05 PM UTC+1, Bill Wortinger wrote:
> 
> > Hello Dan, thanks again for all the help but I can't seem to get anything  
> > to return. Here is my full code, there has to be something I'm missing.  
> > Maybe in the indexing, the mapping?
> > 
> > Mapping:  
> > putMappingResponse = new PutMappingRequestBuilder(newClient  
> > .admin().indices())  
> > .setIndices(INDEX\_NAME)  
> > .setType(INDEX\_TYPE)  
> > .setSource(jsonBuilder().startObject("suggest")  
> > .field("type", "completion")  
> > .endObject().execute().actionGet());
> > 
> > Method:  
> > public String searchSuggestions(String suggestion) {  
> > // Creates suggestions based on Document Titles.  
> > String toReturn = "";
> > 
> > Client localClient = getElasticSearchClient();
> > 
> > CompletionSuggestionBuilder compBuilder = new  
> > CompletionSuggestionBuilder("completion");  
> > compBuilder.text(suggestion);  
> > compBuilder.field("suggest");
> > 
> > SuggestRequestBuilder suggestRequestBuilder = localClient  
> > .prepareSuggest(INDEX\_NAME).addSuggestion(compBuilder);
> > 
> > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > ).actionGet();  
> > CompletionSuggestion compSuggestion = suggestResponse.getSuggest().  
> > getSuggestion("completion");
> > 
> > List\<CompletionSuggestion.Entry\> entryList = compSuggestion.getEntries();  
> > if (entryList != null) {  
> > CompletionSuggestion.Entry entry = entryList.get(0);  
> > List\<CompletionSuggestion.Entry.Option\> options = entry.getOptions();  
> > if (options != null) {  
> > CompletionSuggestion.Entry.Option option = options.get(0);  
> > toReturn = option.getText().string();  
> > }  
> > }  
> > return toReturn;  
> > }
> > 
> > Index:  
> > response = localClient.prepareIndex(INDEX\_NAME, INDEX\_TYPE)  
> > .setSource(jsonBuilder().startObject("suggest").field("  
> > input","FooFighters").endObject()).execute().actionGet();
> > 
> > Thanks for all the help, I'm basically shooting in the dark hoping  
> > somebody with more experience can spot the issue.
> > 
> > On Wed, Apr 9, 2014 at 3:56 AM, Dan Tuffery [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > 
> > > This looks wrong,
> > > 
> > > _Suggest.Suggestion.Entry.Option option2 =  
> > > suggestResponse.getSuggest().getSuggestion("completion").getEntries().get(0).getOptions().get(0);_
> > > 
> > > it should be:
> > > 
> > > \*Suggest.Suggestion.Entry.Option option2 = \*  
> > > _suggestResponse.getSuggest().getSuggestion("suggest").getEntries().get(0).getOptions().get(0);_
> > > 
> > > Where _getSuggestion_ is getting the field name you supplied in the  
> > > request.
> > > 
> > > Dan
> > > 
> > > So it looks like your query is returning zero results. Can you see  
> > > values indexed for the field 'at'
> > > 
> > > On Tuesday, April 8, 2014 4:07:57 PM UTC+1, Bill Wortinger wrote:
> > > 
> > > > Great resource! Thank you,
> > > > 
> > > > _CompletionSuggestionBuilder compBuilder = new  
> > > > CompletionSuggestionBuilder("completion");  
> > > > compBuilder.text(suggestion); compBuilder.field("suggest");  
> > > > SuggestRequestBuilder suggestRequestBuilder =  
> > > > localClient.prepareSuggest(INDEX\_NAME)  
> > > > .addSuggestion(compBuilder); SuggestResponse suggestResponse  
> > > > = suggestRequestBuilder.execute().actionGet();_
> > > > 
> > > > When executing
> > > > 
> > > > _Suggest.Suggestion.Entry.Option option2 =  
> > > > suggestResponse.getSuggest().getSuggestion("completion").getEntries().get(0).getOptions().get(0);_  
> > > > A null is returned.
> > > > 
> > > > Below is my index.
> > > > 
> > > > _.startObject("suggest").field("type", "completion").endObject()_
> > > > 
> > > > Thanks again!
> > > > 
> > > > On Tue, Apr 8, 2014 at 9:14 AM, Dan [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > > 
> > > > > What is the issue you're seeing? Have a look at the examples in the  
> > > > > tests:
> > > > > 
> > > > > [GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine](https://github.com/elasticsearch/elasticsearch/blob/master/)  
> > > > > src/test/java/org/elasticsearch/search/suggest/CompletionSug  
> > > > > gestSearchTests.java
> > > > > 
> > > > > Dan
> > > > > 
> > > > > On Tuesday, April 8, 2014 1:43:29 PM UTC+1, Bill Wortinger wrote:
> > > > > 
> > > > > > Thanks for the heads up Alex, I'll remove the .setTypes().
> > > > > > 
> > > > > > Dan, this is what I have so far;
> > > > > > 
> > > > > > CompletionSuggestionBuilder compBuilder = new  
> > > > > > CompletionSuggestionBuilder("complete");  
> > > > > > compBuilder.text('n");  
> > > > > > compBuilder.field("suggest");  
> > > > > > SuggestRequestBuilder suggestRequestBuilder =  
> > > > > > client.prepareSuggest(INDEX\_NAME);  
> > > > > > suggestRequestBuilder.addSuggestion(compBuilder);  
> > > > > > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > > > > > ).actionGet();
> > > > > > 
> > > > > > CompletionSuggestion compSuggestion = suggestResponse.getSuggest().g  
> > > > > > etSuggestion("complete");
> > > > > > 
> > > > > > List\<CompletionSuggestion.Entry\> entryList =  
> > > > > > compSuggestion.getEntries();  
> > > > > > if(entryList != null) {  
> > > > > > CompletionSuggestion.Entry entry = entryList.get(0);  
> > > > > > List\<CompletionSuggestion.Entry.Option\> options  
> > > > > > =entry.getOptions();  
> > > > > > if(options != null) {  
> > > > > > CompletionSuggestion.Entry.Option option =  
> > > > > > options.get(0);  
> > > > > > toReturn = option.getText().string();  
> > > > > > }  
> > > > > > }  
> > > > > > return toReturn;
> > > > > > 
> > > > > > I've made progress! But now it's falling apart when I try parsing the  
> > > > > > entries from the suggestReponse. So, am I doing this correctly? Missing  
> > > > > > something?
> > > > > > 
> > > > > > Thanks!
> > > > > > 
> > > > > > > 
> > > > > > 
> > > > > > On Monday, April 7, 2014 6:26:37 AM UTC-4, Dan wrote:
> > > > > > 
> > > > > > > Use the SuggestRequestBuilder, i.e.
> > > > > > > 
> > > > > > > CompletionSuggestionBuilder compBuilder = new  
> > > > > > > CompletionSuggestionBuilder("complete");  
> > > > > > > compBuilder.text("n");  
> > > > > > > compBuilder.field("suggest");
> > > > > > > 
> > > > > > > SuggestRequestBuilder suggestRequestBuilder =  
> > > > > > > client.prepareSuggest(INDEX\_NAME);  
> > > > > > > suggestRequestBuilder.addSuggestion(compBuilder);  
> > > > > > > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > > > > > > ).actionGet();
> > > > > > > 
> > > > > > > Dan
> > > > > > > 
> > > > > > > On Mon, Apr 7, 2014 at 8:49 AM, Alexander Reelsen \<[a...@spinscale.de](mailto:a...@spinscale.de)
> > > > > > > 
> > > > > > > > wrote:
> > > > > > > 
> > > > > > > > Hey,
> > > > > > > > 
> > > > > > > > looks ok. Minor note: Types are simply ignored for suggestions.  
> > > > > > > > What are you getting back? Nothing?  
> > > > > > > > Can you create a fully working gist, including creation of the  
> > > > > > > > mapping and indexing? Then debugging and finding your possible cause would  
> > > > > > > > be a lot easier.
> > > > > > > > 
> > > > > > > > --Alex
> > > > > > > > 
> > > > > > > > On Fri, Apr 4, 2014 at 4:02 PM, Bill Wortinger [r3dr...@gmail.com](mailto:r3dr...@gmail.com)wrote:
> > > > > > > > 
> > > > > > > > > I have my indices created, and mapping type for my 'suggest' field  
> > > > > > > > > set to completion. I can't figure out how to configure the query for  
> > > > > > > > > completion suggestions in elastic-search (Java API).
> > > > > > > > > 
> > > > > > > > > I'm trying to use this Query to base my implementation off of. "song-suggest" : { "text" : "n", "completion" : { "field" : "suggest" } } Here's  
> > > > > > > > > what I have so far,
> > > > > > > > > 
> > > > > > > > > ```
> > > > > > > > > CompletionSuggestionBuilder compBuilder = new CompletionSuggestionBuilder("complete");
> > > > > > > > > compBuilder.text("n..");
> > > > > > > > > compBuilder.field("suggest");
> > > > > > > > > 
> > > > > > > > > SearchResponse searchResponse = localClient.prepareSearch(INDEX_NAME)
> > > > > > > > > .setTypes("completion")
> > > > > > > > > .setQuery(QueryBuilders.matchAllQuery())
> > > > > > > > > .addSuggestion(compBuilder)
> > > > > > > > > .execute().actionGet();
> > > > > > > > > 
> > > > > > > > > CompletionSuggestion compSuggestion = searchResponse.getSuggest().getSuggestion("complete");
> > > > > > > > > 
> > > > > > > > > ```
> > > > > > > > > 
> > > > > > > > > Am I missing something, doing something wrong? Thanks!
> > > > > > > > > 
> > > > > > > > > --  
> > > > > > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > > > > To view this discussion on the web visit  
> > > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/06792c37-646](https://groups.google.com/d/msgid/elasticsearch/06792c37-646)  
> > > > > > > > > c-4b59-bdb3-f23cc51bd134%[40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > > > To view this discussion on the web visit  
> > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76G](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76G)  
> > > > > > > > mrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%[40mail.gmail.com](http://40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%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 a topic in the  
> > > > > > > Google Groups "elasticsearch" group.  
> > > > > > > To unsubscribe from this topic, visit [https://groups.google.com/d/to](https://groups.google.com/d/to)  
> > > > > > > pic/elasticsearch/06nbxJnYfDo/unsubscribe.  
> > > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > > > msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40goo  
> > > > > > > [glegroups.com](http://glegroups.com)[https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.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 a topic in the  
> > > > Google Groups "elasticsearch" group.  
> > > > To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > topic/elasticsearch/06nbxJnYfDo/unsubscribe.  
> > > > To unsubscribe from this group and all its topics, send an email to  
> > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%  
> > > > [40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.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 a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/06nbxJnYfDo/unsubscribe](https://groups.google.com/d/topic/elasticsearch/06nbxJnYfDo/unsubscribe).  
> > To unsubscribe from this group and all its topics, 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/3e73ca3a-9f27-417a-b097-846dfa4730d0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3e73ca3a-9f27-417a-b097-846dfa4730d0%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/3e73ca3a-9f27-417a-b097-846dfa4730d0%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/3e73ca3a-9f27-417a-b097-846dfa4730d0%40googlegroups.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/CAJ%3D6wEdt%2B-X7YL1q799rvE%2BdH%3DmZozyXyLEhpq1aANfBsTb-Ow%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAJ%3D6wEdt%2B-X7YL1q799rvE%2BdH%3DmZozyXyLEhpq1aANfBsTb-Ow%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [April 15, 2014, 2:44pm UTC](https://discuss.elastic.co/t/querying-with-completion-suggesters-with-java-api/16822/12 "2014-04-15T14:44:23Z")

</div>

You're missing the index 'type' and 'properties' objects from the index  
mapping. Change it to:

new PutMappingRequestBuilder(newClient  
.admin().indices())  
.setIndices(INDEX\_NAME)  
.setType(INDEX\_TYPE)  
.setSource(jsonBuilder().startObject(INDEX\_TYPE)  
.startObject("properties")  
.startObject("suggest")  
.field("type", "completion")  
.endObject()  
.endObject()  
.endObject().execute().actionGet());

Which will create the JSON:

{  
"test": {  
"properties": {  
"suggest": {  
"type": "completion"  
}  
}  
}  
}

Dan

On Tuesday, April 15, 2014 2:31:01 PM UTC+1, Bill Wortinger wrote:

> Hey Dan!
> 
> Thanks for the code snippet, it's actually helped me narrow down my  
> problem considerably. I'm getting the error;
> 
> field 'suggest' is not a completion suggest field.
> 
> To my knowledge, you define it as a completion suggest field with the type  
> in the mapping.
> 
> .field("suggest").startObject().field("type", "completion").endObject()
> 
> Thanks!
> 
> On Fri, Apr 11, 2014 at 1:11 AM, Dan Tuffery \<[dan.t...@gmail.com](mailto:dan.t...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > I did a quick test, this works:
> > 
> > _Create mapping_
> > 
> > curl -XPUT '[http://localhost:9200/example/test/\_mapping](http://localhost:9200/example/test/_mapping)' -d  
> > '{  
> > "test": {  
> > "properties": {  
> > "my\_suggest": {  
> > "type": "completion"  
> > }  
> > }  
> > }  
> > }'
> > 
> > _Index value_
> > 
> > curl -XPUT '[http://localhost:9200/example/test/1/](http://localhost:9200/example/test/1/)' -d  
> > '{  
> > "my\_suggest": "FooFighters"  
> > }'
> > 
> > _Java API code_
> > 
> > CompletionSuggestionBuilder compBuilder = new  
> > CompletionSuggestionBuilder("my\_suggest");  
> > compBuilder.text("Foo");  
> > compBuilder.field("my\_suggest");
> > 
> > SuggestRequestBuilder suggestRequestBuilder = client  
> > .prepareSuggest("example").addSuggestion(compBuilder);
> > 
> > SuggestResponse suggestResponse =  
> > suggestRequestBuilder.execute().actionGet();  
> > CompletionSuggestion compSuggestion =  
> > suggestResponse.getSuggest().getSuggestion("my\_suggest");
> > 
> > List\<CompletionSuggestion.Entry\> entryList = compSuggestion.getEntries();  
> > if (entryList != null) {  
> > CompletionSuggestion.Entry entry = entryList.get(0);  
> > List\<CompletionSuggestion.Entry.Option\> options = entry.getOptions();  
> > if (options != null) {  
> > CompletionSuggestion.Entry.Option option = options.get(0);  
> > //the value of toReturn is 'FooFighters'  
> > String toReturn = option.getText().string()  
> > }
> > 
> > Dan
> > 
> > On Thursday, April 10, 2014 2:50:05 PM UTC+1, Bill Wortinger wrote:
> > 
> > > Hello Dan, thanks again for all the help but I can't seem to get  
> > > anything to return. Here is my full code, there has to be something I'm  
> > > missing. Maybe in the indexing, the mapping?
> > > 
> > > Mapping:  
> > > putMappingResponse = new PutMappingRequestBuilder(newClient  
> > > .admin().indices())  
> > > .setIndices(INDEX\_NAME)  
> > > .setType(INDEX\_TYPE)  
> > > .setSource(jsonBuilder().startObject("suggest")  
> > > .field("type", "completion")  
> > > .endObject().execute().actionGet());
> > > 
> > > Method:  
> > > public String searchSuggestions(String suggestion) {  
> > > // Creates suggestions based on Document Titles.  
> > > String toReturn = "";
> > > 
> > > Client localClient = getElasticSearchClient();
> > > 
> > > CompletionSuggestionBuilder compBuilder = new  
> > > CompletionSuggestionBuilder("completion");  
> > > compBuilder.text(suggestion);  
> > > compBuilder.field("suggest");
> > > 
> > > SuggestRequestBuilder suggestRequestBuilder = localClient  
> > > .prepareSuggest(INDEX\_NAME).addSuggestion(compBuilder);
> > > 
> > > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > > ).actionGet();  
> > > CompletionSuggestion compSuggestion = suggestResponse.getSuggest().  
> > > getSuggestion("completion");
> > > 
> > > List\<CompletionSuggestion.Entry\> entryList =  
> > > compSuggestion.getEntries();  
> > > if (entryList != null) {  
> > > CompletionSuggestion.Entry entry = entryList.get(0);  
> > > List\<CompletionSuggestion.Entry.Option\> options = entry.getOptions();  
> > > if (options != null) {  
> > > CompletionSuggestion.Entry.Option option = options.get(0);  
> > > toReturn = option.getText().string();  
> > > }  
> > > }  
> > > return toReturn;  
> > > }
> > > 
> > > Index:  
> > > response = localClient.prepareIndex(INDEX\_NAME, INDEX\_TYPE)  
> > > .setSource(jsonBuilder().startObject("suggest").field("  
> > > input","FooFighters").endObject()).execute().actionGet();
> > > 
> > > Thanks for all the help, I'm basically shooting in the dark hoping  
> > > somebody with more experience can spot the issue.
> > > 
> > > On Wed, Apr 9, 2014 at 3:56 AM, Dan Tuffery [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > 
> > > > This looks wrong,
> > > > 
> > > > _Suggest.Suggestion.Entry.Option option2 =  
> > > > suggestResponse.getSuggest().getSuggestion("completion").getEntries().get(0).getOptions().get(0);_
> > > > 
> > > > it should be:
> > > > 
> > > > \*Suggest.Suggestion.Entry.Option option2 = \*  
> > > > _suggestResponse.getSuggest().getSuggestion("suggest").getEntries().get(0).getOptions().get(0);_
> > > > 
> > > > Where _getSuggestion_ is getting the field name you supplied in the  
> > > > request.
> > > > 
> > > > Dan
> > > > 
> > > > So it looks like your query is returning zero results. Can you see  
> > > > values indexed for the field 'at'
> > > > 
> > > > On Tuesday, April 8, 2014 4:07:57 PM UTC+1, Bill Wortinger wrote:
> > > > 
> > > > > Great resource! Thank you,
> > > > > 
> > > > > _CompletionSuggestionBuilder compBuilder = new  
> > > > > CompletionSuggestionBuilder("completion");  
> > > > > compBuilder.text(suggestion); compBuilder.field("suggest");  
> > > > > SuggestRequestBuilder suggestRequestBuilder =  
> > > > > localClient.prepareSuggest(INDEX\_NAME)  
> > > > > .addSuggestion(compBuilder); SuggestResponse suggestResponse  
> > > > > = suggestRequestBuilder.execute().actionGet();_
> > > > > 
> > > > > When executing
> > > > > 
> > > > > \*Suggest.Suggestion.Entry.Option option2 =  
> > > > > suggestResponse.getSuggest().getSuggestion("completion").getEntries().get(0).getOptions().get(0);  
> > > > > \*  
> > > > > A null is returned.
> > > > > 
> > > > > Below is my index.
> > > > > 
> > > > > _.startObject("suggest").field("type", "completion").endObject()_
> > > > > 
> > > > > Thanks again!
> > > > > 
> > > > > On Tue, Apr 8, 2014 at 9:14 AM, Dan [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > > > 
> > > > > > What is the issue you're seeing? Have a look at the examples in the  
> > > > > > tests:
> > > > > > 
> > > > > > [GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine](https://github.com/elasticsearch/elasticsearch/blob/master/)  
> > > > > > src/test/java/org/elasticsearch/search/suggest/CompletionSug  
> > > > > > gestSearchTests.java
> > > > > > 
> > > > > > Dan
> > > > > > 
> > > > > > On Tuesday, April 8, 2014 1:43:29 PM UTC+1, Bill Wortinger wrote:
> > > > > > 
> > > > > > > Thanks for the heads up Alex, I'll remove the .setTypes().
> > > > > > > 
> > > > > > > Dan, this is what I have so far;
> > > > > > > 
> > > > > > > CompletionSuggestionBuilder compBuilder = new  
> > > > > > > CompletionSuggestionBuilder("complete");  
> > > > > > > compBuilder.text('n");  
> > > > > > > compBuilder.field("suggest");  
> > > > > > > SuggestRequestBuilder suggestRequestBuilder =  
> > > > > > > client.prepareSuggest(INDEX\_NAME);  
> > > > > > > suggestRequestBuilder.addSuggestion(compBuilder);  
> > > > > > > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > > > > > > ).actionGet();
> > > > > > > 
> > > > > > > CompletionSuggestion compSuggestion = suggestResponse.getSuggest().g  
> > > > > > > etSuggestion("complete");
> > > > > > > 
> > > > > > > List\<CompletionSuggestion.Entry\> entryList =  
> > > > > > > compSuggestion.getEntries();  
> > > > > > > if(entryList != null) {  
> > > > > > > CompletionSuggestion.Entry entry = entryList.get(0);  
> > > > > > > List\<CompletionSuggestion.Entry.Option\> options  
> > > > > > > =entry.getOptions();  
> > > > > > > if(options != null) {  
> > > > > > > CompletionSuggestion.Entry.Option option =  
> > > > > > > options.get(0);  
> > > > > > > toReturn = option.getText().string();  
> > > > > > > }  
> > > > > > > }  
> > > > > > > return toReturn;
> > > > > > > 
> > > > > > > I've made progress! But now it's falling apart when I try parsing  
> > > > > > > the entries from the suggestReponse. So, am I doing this correctly? Missing  
> > > > > > > something?
> > > > > > > 
> > > > > > > Thanks!
> > > > > > > 
> > > > > > > > 
> > > > > > > 
> > > > > > > On Monday, April 7, 2014 6:26:37 AM UTC-4, Dan wrote:
> > > > > > > 
> > > > > > > > Use the SuggestRequestBuilder, i.e.
> > > > > > > > 
> > > > > > > > CompletionSuggestionBuilder compBuilder = new  
> > > > > > > > CompletionSuggestionBuilder("complete");  
> > > > > > > > compBuilder.text("n");  
> > > > > > > > compBuilder.field("suggest");
> > > > > > > > 
> > > > > > > > SuggestRequestBuilder suggestRequestBuilder =  
> > > > > > > > client.prepareSuggest(INDEX\_NAME);  
> > > > > > > > suggestRequestBuilder.addSuggestion(compBuilder);  
> > > > > > > > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > > > > > > > ).actionGet();
> > > > > > > > 
> > > > > > > > Dan
> > > > > > > > 
> > > > > > > > On Mon, Apr 7, 2014 at 8:49 AM, Alexander Reelsen \<  
> > > > > > > > [a...@spinscale.de](mailto:a...@spinscale.de)\> wrote:
> > > > > > > > 
> > > > > > > > > Hey,
> > > > > > > > > 
> > > > > > > > > looks ok. Minor note: Types are simply ignored for suggestions.  
> > > > > > > > > What are you getting back? Nothing?  
> > > > > > > > > Can you create a fully working gist, including creation of the  
> > > > > > > > > mapping and indexing? Then debugging and finding your possible cause would  
> > > > > > > > > be a lot easier.
> > > > > > > > > 
> > > > > > > > > --Alex
> > > > > > > > > 
> > > > > > > > > On Fri, Apr 4, 2014 at 4:02 PM, Bill Wortinger [r3dr...@gmail.com](mailto:r3dr...@gmail.com)wrote:
> > > > > > > > > 
> > > > > > > > > > I have my indices created, and mapping type for my 'suggest'  
> > > > > > > > > > field set to completion. I can't figure out how to configure the query for  
> > > > > > > > > > completion suggestions in elastic-search (Java API).
> > > > > > > > > > 
> > > > > > > > > > I'm trying to use this Query to base my implementation off of. "song-suggest" : { "text" : "n", "completion" : { "field" : "suggest" } } Here's  
> > > > > > > > > > what I have so far,
> > > > > > > > > > 
> > > > > > > > > > ```
> > > > > > > > > > CompletionSuggestionBuilder compBuilder = new CompletionSuggestionBuilder("complete"); 
> > > > > > > > > > compBuilder.text("n..");
> > > > > > > > > > compBuilder.field("suggest");
> > > > > > > > > > 
> > > > > > > > > > SearchResponse searchResponse = localClient.prepareSearch(INDEX_NAME)
> > > > > > > > > > .setTypes("completion")
> > > > > > > > > > .setQuery(QueryBuilders.matchAllQuery())
> > > > > > > > > > .addSuggestion(compBuilder)
> > > > > > > > > > .execute().actionGet();
> > > > > > > > > > 
> > > > > > > > > > CompletionSuggestion compSuggestion = searchResponse.getSuggest().getSuggestion("complete");
> > > > > > > > > > 
> > > > > > > > > > ```
> > > > > > > > > > 
> > > > > > > > > > Am I missing something, doing something wrong? Thanks!
> > > > > > > > > > 
> > > > > > > > > > --  
> > > > > > > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > > > > > To view this discussion on the web visit  
> > > > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/06792c37-646](https://groups.google.com/d/msgid/elasticsearch/06792c37-646)  
> > > > > > > > > > c-4b59-bdb3-f23cc51bd134%[40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > > > > To view this discussion on the web visit  
> > > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76G](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76G)  
> > > > > > > > > mrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%[40mail.gmail.com](http://40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%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 a topic in  
> > > > > > > > the Google Groups "elasticsearch" group.  
> > > > > > > > To unsubscribe from this topic, visit [https://groups.google.com/d/to](https://groups.google.com/d/to)  
> > > > > > > > pic/elasticsearch/06nbxJnYfDo/unsubscribe.  
> > > > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > > > > msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40goo  
> > > > > > > > [glegroups.com](http://glegroups.com)[https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.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 a topic in the  
> > > > > Google Groups "elasticsearch" group.  
> > > > > To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > topic/elasticsearch/06nbxJnYfDo/unsubscribe.  
> > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%  
> > > > > [40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.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 a topic in the  
> > > Google Groups "elasticsearch" group.  
> > > To unsubscribe from this topic, visit  
> > > [https://groups.google.com/d/topic/elasticsearch/06nbxJnYfDo/unsubscribe](https://groups.google.com/d/topic/elasticsearch/06nbxJnYfDo/unsubscribe).  
> > > To unsubscribe from this group and all its topics, send an email to  
> > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/3e73ca3a-9f27-417a-b097-846dfa4730d0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3e73ca3a-9f27-417a-b097-846dfa4730d0%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/3e73ca3a-9f27-417a-b097-846dfa4730d0%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/3e73ca3a-9f27-417a-b097-846dfa4730d0%40googlegroups.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/8f1497f0-ad82-42d5-9688-f86fd295901e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8f1497f0-ad82-42d5-9688-f86fd295901e%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [April 15, 2014, 4:48pm UTC](https://discuss.elastic.co/t/querying-with-completion-suggesters-with-java-api/16822/13 "2014-04-15T16:48:20Z")

</div>

The previous example is missing the first startObject/endObject:

new PutMappingRequestBuilder(newClient  
.admin().indices())  
.setIndices(INDEX\_NAME)  
.setType(INDEX\_TYPE)  
.setSource(jsonBuilder().startObject().startObject(INDEX\_TYPE)  
.startObject("properties")  
.startObject("suggest")  
.field("type", "completion")  
.endObject()  
.endObject()  
.endObject()  
.endObject().execute().actionGet());

Dan

On Tuesday, April 15, 2014 3:44:23 PM UTC+1, Dan Tuffery wrote:

> You're missing the index 'type' and 'properties' objects from the index  
> mapping. Change it to:
> 
> new PutMappingRequestBuilder(newClient  
> .admin().indices())  
> .setIndices(INDEX\_NAME)  
> .setType(INDEX\_TYPE)  
> .setSource(jsonBuilder().startObject(INDEX\_TYPE)  
> .startObject("properties")  
> .startObject("suggest")  
> .field("type", "completion")  
> .endObject()  
> .endObject()  
> .endObject().execute().actionGet());
> 
> Which will create the JSON:
> 
> {  
> "test": {  
> "properties": {  
> "suggest": {  
> "type": "completion"  
> }  
> }  
> }  
> }
> 
> Dan
> 
> On Tuesday, April 15, 2014 2:31:01 PM UTC+1, Bill Wortinger wrote:
> 
> > Hey Dan!
> > 
> > Thanks for the code snippet, it's actually helped me narrow down my  
> > problem considerably. I'm getting the error;
> > 
> > field 'suggest' is not a completion suggest field.
> > 
> > To my knowledge, you define it as a completion suggest field with the  
> > type in the mapping.
> > 
> > .field("suggest").startObject().field("type", "completion").endObject()
> > 
> > Thanks!
> > 
> > On Fri, Apr 11, 2014 at 1:11 AM, Dan Tuffery [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > 
> > > I did a quick test, this works:
> > > 
> > > _Create mapping_
> > > 
> > > curl -XPUT '[http://localhost:9200/example/test/\_mapping](http://localhost:9200/example/test/_mapping)' -d  
> > > '{  
> > > "test": {  
> > > "properties": {  
> > > "my\_suggest": {  
> > > "type": "completion"  
> > > }  
> > > }  
> > > }  
> > > }'
> > > 
> > > _Index value_
> > > 
> > > curl -XPUT '[http://localhost:9200/example/test/1/](http://localhost:9200/example/test/1/)' -d  
> > > '{  
> > > "my\_suggest": "FooFighters"  
> > > }'
> > > 
> > > _Java API code_
> > > 
> > > CompletionSuggestionBuilder compBuilder = new  
> > > CompletionSuggestionBuilder("my\_suggest");  
> > > compBuilder.text("Foo");  
> > > compBuilder.field("my\_suggest");
> > > 
> > > SuggestRequestBuilder suggestRequestBuilder = client  
> > > .prepareSuggest("example").addSuggestion(compBuilder);
> > > 
> > > SuggestResponse suggestResponse =  
> > > suggestRequestBuilder.execute().actionGet();  
> > > CompletionSuggestion compSuggestion =  
> > > suggestResponse.getSuggest().getSuggestion("my\_suggest");
> > > 
> > > List\<CompletionSuggestion.Entry\> entryList = compSuggestion.getEntries();  
> > > if (entryList != null) {  
> > > CompletionSuggestion.Entry entry = entryList.get(0);  
> > > List\<CompletionSuggestion.Entry.Option\> options = entry.getOptions();  
> > > if (options != null) {  
> > > CompletionSuggestion.Entry.Option option = options.get(0);  
> > > //the value of toReturn is 'FooFighters'  
> > > String toReturn = option.getText().string()  
> > > }
> > > 
> > > Dan
> > > 
> > > On Thursday, April 10, 2014 2:50:05 PM UTC+1, Bill Wortinger wrote:
> > > 
> > > > Hello Dan, thanks again for all the help but I can't seem to get  
> > > > anything to return. Here is my full code, there has to be something I'm  
> > > > missing. Maybe in the indexing, the mapping?
> > > > 
> > > > Mapping:  
> > > > putMappingResponse = new PutMappingRequestBuilder(newClient  
> > > > .admin().indices())  
> > > > .setIndices(INDEX\_NAME)  
> > > > .setType(INDEX\_TYPE)  
> > > > .setSource(jsonBuilder().startObject("suggest")  
> > > > .field("type", "completion")  
> > > > .endObject().execute().actionGet());
> > > > 
> > > > Method:  
> > > > public String searchSuggestions(String suggestion) {  
> > > > // Creates suggestions based on Document Titles.  
> > > > String toReturn = "";
> > > > 
> > > > Client localClient = getElasticSearchClient();
> > > > 
> > > > CompletionSuggestionBuilder compBuilder = new  
> > > > CompletionSuggestionBuilder("completion");  
> > > > compBuilder.text(suggestion);  
> > > > compBuilder.field("suggest");
> > > > 
> > > > SuggestRequestBuilder suggestRequestBuilder = localClient  
> > > > .prepareSuggest(INDEX\_NAME).addSuggestion(compBuilder);
> > > > 
> > > > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > > > ).actionGet();  
> > > > CompletionSuggestion compSuggestion = suggestResponse.getSuggest().  
> > > > getSuggestion("completion");
> > > > 
> > > > List\<CompletionSuggestion.Entry\> entryList =  
> > > > compSuggestion.getEntries();  
> > > > if (entryList != null) {  
> > > > CompletionSuggestion.Entry entry = entryList.get(0);  
> > > > List\<CompletionSuggestion.Entry.Option\> options = entry.getOptions();  
> > > > if (options != null) {  
> > > > CompletionSuggestion.Entry.Option option = options.get(0);  
> > > > toReturn = option.getText().string();  
> > > > }  
> > > > }  
> > > > return toReturn;  
> > > > }
> > > > 
> > > > Index:  
> > > > response = localClient.prepareIndex(INDEX\_NAME, INDEX\_TYPE)  
> > > > .setSource(jsonBuilder().startObject("suggest").field("  
> > > > input","FooFighters").endObject()).execute().actionGet();
> > > > 
> > > > Thanks for all the help, I'm basically shooting in the dark hoping  
> > > > somebody with more experience can spot the issue.
> > > > 
> > > > On Wed, Apr 9, 2014 at 3:56 AM, Dan Tuffery [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > > 
> > > > > This looks wrong,
> > > > > 
> > > > > _Suggest.Suggestion.Entry.Option option2 =  
> > > > > suggestResponse.getSuggest().getSuggestion("completion").getEntries().get(0).getOptions().get(0);_
> > > > > 
> > > > > it should be:
> > > > > 
> > > > > \*Suggest.Suggestion.Entry.Option option2 = \*  
> > > > > _suggestResponse.getSuggest().getSuggestion("suggest").getEntries().get(0).getOptions().get(0);_
> > > > > 
> > > > > Where _getSuggestion_ is getting the field name you supplied in the  
> > > > > request.
> > > > > 
> > > > > Dan
> > > > > 
> > > > > So it looks like your query is returning zero results. Can you see  
> > > > > values indexed for the field 'at'
> > > > > 
> > > > > On Tuesday, April 8, 2014 4:07:57 PM UTC+1, Bill Wortinger wrote:
> > > > > 
> > > > > > Great resource! Thank you,
> > > > > > 
> > > > > > _CompletionSuggestionBuilder compBuilder = new  
> > > > > > CompletionSuggestionBuilder("completion");  
> > > > > > compBuilder.text(suggestion); compBuilder.field("suggest");  
> > > > > > SuggestRequestBuilder suggestRequestBuilder =  
> > > > > > localClient.prepareSuggest(INDEX\_NAME)  
> > > > > > .addSuggestion(compBuilder); SuggestResponse suggestResponse  
> > > > > > = suggestRequestBuilder.execute().actionGet();_
> > > > > > 
> > > > > > When executing
> > > > > > 
> > > > > > \*Suggest.Suggestion.Entry.Option option2 =  
> > > > > > suggestResponse.getSuggest().getSuggestion("completion").getEntries().get(0).getOptions().get(0);  
> > > > > > \*  
> > > > > > A null is returned.
> > > > > > 
> > > > > > Below is my index.
> > > > > > 
> > > > > > _.startObject("suggest").field("type", "completion").endObject()_
> > > > > > 
> > > > > > Thanks again!
> > > > > > 
> > > > > > On Tue, Apr 8, 2014 at 9:14 AM, Dan [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > > > > 
> > > > > > > What is the issue you're seeing? Have a look at the examples in the  
> > > > > > > tests:
> > > > > > > 
> > > > > > > [GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine](https://github.com/elasticsearch/elasticsearch/blob/master/)  
> > > > > > > src/test/java/org/elasticsearch/search/suggest/CompletionSug  
> > > > > > > gestSearchTests.java
> > > > > > > 
> > > > > > > Dan
> > > > > > > 
> > > > > > > On Tuesday, April 8, 2014 1:43:29 PM UTC+1, Bill Wortinger wrote:
> > > > > > > 
> > > > > > > > Thanks for the heads up Alex, I'll remove the .setTypes().
> > > > > > > > 
> > > > > > > > Dan, this is what I have so far;
> > > > > > > > 
> > > > > > > > CompletionSuggestionBuilder compBuilder = new  
> > > > > > > > CompletionSuggestionBuilder("complete");  
> > > > > > > > compBuilder.text('n");  
> > > > > > > > compBuilder.field("suggest");  
> > > > > > > > SuggestRequestBuilder suggestRequestBuilder =  
> > > > > > > > client.prepareSuggest(INDEX\_NAME);  
> > > > > > > > suggestRequestBuilder.addSuggestion(compBuilder);  
> > > > > > > > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > > > > > > > ).actionGet();
> > > > > > > > 
> > > > > > > > CompletionSuggestion compSuggestion = suggestResponse.getSuggest().  
> > > > > > > > getSuggestion("complete");
> > > > > > > > 
> > > > > > > > List\<CompletionSuggestion.Entry\> entryList =  
> > > > > > > > compSuggestion.getEntries();  
> > > > > > > > if(entryList != null) {  
> > > > > > > > CompletionSuggestion.Entry entry = entryList.get(0);  
> > > > > > > > List\<CompletionSuggestion.Entry.Option\> options  
> > > > > > > > =entry.getOptions();  
> > > > > > > > if(options != null) {  
> > > > > > > > CompletionSuggestion.Entry.Option option =  
> > > > > > > > options.get(0);  
> > > > > > > > toReturn = option.getText().string();  
> > > > > > > > }  
> > > > > > > > }  
> > > > > > > > return toReturn;
> > > > > > > > 
> > > > > > > > I've made progress! But now it's falling apart when I try parsing  
> > > > > > > > the entries from the suggestReponse. So, am I doing this correctly? Missing  
> > > > > > > > something?
> > > > > > > > 
> > > > > > > > Thanks!
> > > > > > > > 
> > > > > > > > > 
> > > > > > > > 
> > > > > > > > On Monday, April 7, 2014 6:26:37 AM UTC-4, Dan wrote:
> > > > > > > > 
> > > > > > > > > Use the SuggestRequestBuilder, i.e.
> > > > > > > > > 
> > > > > > > > > CompletionSuggestionBuilder compBuilder = new  
> > > > > > > > > CompletionSuggestionBuilder("complete");  
> > > > > > > > > compBuilder.text("n");  
> > > > > > > > > compBuilder.field("suggest");
> > > > > > > > > 
> > > > > > > > > SuggestRequestBuilder suggestRequestBuilder =  
> > > > > > > > > client.prepareSuggest(INDEX\_NAME);  
> > > > > > > > > suggestRequestBuilder.addSuggestion(compBuilder);  
> > > > > > > > > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > > > > > > > > ).actionGet();
> > > > > > > > > 
> > > > > > > > > Dan
> > > > > > > > > 
> > > > > > > > > On Mon, Apr 7, 2014 at 8:49 AM, Alexander Reelsen \<  
> > > > > > > > > [a...@spinscale.de](mailto:a...@spinscale.de)\> wrote:
> > > > > > > > > 
> > > > > > > > > > Hey,
> > > > > > > > > > 
> > > > > > > > > > looks ok. Minor note: Types are simply ignored for suggestions.  
> > > > > > > > > > What are you getting back? Nothing?  
> > > > > > > > > > Can you create a fully working gist, including creation of the  
> > > > > > > > > > mapping and indexing? Then debugging and finding your possible cause would  
> > > > > > > > > > be a lot easier.
> > > > > > > > > > 
> > > > > > > > > > --Alex
> > > > > > > > > > 
> > > > > > > > > > On Fri, Apr 4, 2014 at 4:02 PM, Bill Wortinger \<[r3dr...@gmail.com](mailto:r3dr...@gmail.com)
> > > > > > > > > > 
> > > > > > > > > > > wrote:
> > > > > > > > > > 
> > > > > > > > > > > I have my indices created, and mapping type for my 'suggest'  
> > > > > > > > > > > field set to completion. I can't figure out how to configure the query for  
> > > > > > > > > > > completion suggestions in elastic-search (Java API).
> > > > > > > > > > > 
> > > > > > > > > > > I'm trying to use this Query to base my implementation off of. "song-suggest" : { "text" : "n", "completion" : { "field" : "suggest" } } Here's  
> > > > > > > > > > > what I have so far,
> > > > > > > > > > > 
> > > > > > > > > > > ```
> > > > > > > > > > > CompletionSuggestionBuilder compBuilder = new CompletionSuggestionBuilder("complete"); 
> > > > > > > > > > > compBuilder.text("n..");
> > > > > > > > > > > compBuilder.field("suggest");
> > > > > > > > > > > 
> > > > > > > > > > > SearchResponse searchResponse = localClient.prepareSearch(INDEX_NAME)
> > > > > > > > > > > .setTypes("completion")
> > > > > > > > > > > .setQuery(QueryBuilders.matchAllQuery())
> > > > > > > > > > > .addSuggestion(compBuilder)
> > > > > > > > > > > .execute().actionGet();
> > > > > > > > > > > 
> > > > > > > > > > > CompletionSuggestion compSuggestion = searchResponse.getSuggest().getSuggestion("complete");
> > > > > > > > > > > 
> > > > > > > > > > > ```
> > > > > > > > > > > 
> > > > > > > > > > > Am I missing something, doing something wrong? Thanks!
> > > > > > > > > > > 
> > > > > > > > > > > --  
> > > > > > > > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > > > > > > To view this discussion on the web visit  
> > > > > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/06792c37-646](https://groups.google.com/d/msgid/elasticsearch/06792c37-646)  
> > > > > > > > > > > c-4b59-bdb3-f23cc51bd134%[40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > > > > > To view this discussion on the web visit  
> > > > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76G](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76G)  
> > > > > > > > > > mrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%[40mail.gmail.com](http://40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%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 a topic in  
> > > > > > > > > the Google Groups "elasticsearch" group.  
> > > > > > > > > To unsubscribe from this topic, visit [https://groups.google.com/d/to](https://groups.google.com/d/to)  
> > > > > > > > > pic/elasticsearch/06nbxJnYfDo/unsubscribe.  
> > > > > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > > > > To view this discussion on the web visit  
> > > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef](https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef)  
> > > > > > > > > 5-4f13-8dce-04e0bcfc5404%[40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.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 a topic in the  
> > > > > > Google Groups "elasticsearch" group.  
> > > > > > To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > > topic/elasticsearch/06nbxJnYfDo/unsubscribe.  
> > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > > msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%  
> > > > > > [40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.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 a topic in the  
> > > > Google Groups "elasticsearch" group.  
> > > > To unsubscribe from this topic, visit  
> > > > [https://groups.google.com/d/topic/elasticsearch/06nbxJnYfDo/unsubscribe](https://groups.google.com/d/topic/elasticsearch/06nbxJnYfDo/unsubscribe).  
> > > > To unsubscribe from this group and all its topics, send an email to  
> > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit  
> > > > [https://groups.google.com/d/msgid/elasticsearch/3e73ca3a-9f27-417a-b097-846dfa4730d0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3e73ca3a-9f27-417a-b097-846dfa4730d0%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/3e73ca3a-9f27-417a-b097-846dfa4730d0%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/3e73ca3a-9f27-417a-b097-846dfa4730d0%40googlegroups.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/413bdb0f-dfc7-49d6-bfaf-3156d11a8e91%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/413bdb0f-dfc7-49d6-bfaf-3156d11a8e91%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Olly\_Shaw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olly_shaw/32/1621_2.png) [@Olly\_Shaw](https://discuss.elastic.co/u/Olly_Shaw)\
**Post date:** [April 28, 2014, 7:37pm UTC](https://discuss.elastic.co/t/querying-with-completion-suggesters-with-java-api/16822/14 "2014-04-28T19:37:19Z")

</div>

Hi Dan, really helpful thanks. I was struggling a bit with the java API.  
This got me going again.  
Olly

On Friday, April 11, 2014 6:11:41 AM UTC+1, Dan Tuffery wrote:

> I did a quick test, this works:
> 
> _Create mapping_
> 
> curl -XPUT '[http://localhost:9200/example/test/\_mapping](http://localhost:9200/example/test/_mapping)' -d  
> '{  
> "test": {  
> "properties": {  
> "my\_suggest": {  
> "type": "completion"  
> }  
> }  
> }  
> }'
> 
> _Index value_
> 
> curl -XPUT '[http://localhost:9200/example/test/1/](http://localhost:9200/example/test/1/)' -d  
> '{  
> "my\_suggest": "FooFighters"  
> }'
> 
> _Java API code_
> 
> CompletionSuggestionBuilder compBuilder = new  
> CompletionSuggestionBuilder("my\_suggest");  
> compBuilder.text("Foo");  
> compBuilder.field("my\_suggest");
> 
> SuggestRequestBuilder suggestRequestBuilder = client  
> .prepareSuggest("example").addSuggestion(compBuilder);
> 
> SuggestResponse suggestResponse =  
> suggestRequestBuilder.execute().actionGet();  
> CompletionSuggestion compSuggestion =  
> suggestResponse.getSuggest().getSuggestion("my\_suggest");
> 
> List\<CompletionSuggestion.Entry\> entryList = compSuggestion.getEntries();  
> if (entryList != null) {  
> CompletionSuggestion.Entry entry = entryList.get(0);  
> List\<CompletionSuggestion.Entry.Option\> options = entry.getOptions();  
> if (options != null) {  
> CompletionSuggestion.Entry.Option option = options.get(0);  
> //the value of toReturn is 'FooFighters'  
> String toReturn = option.getText().string()  
> }
> 
> Dan
> 
> On Thursday, April 10, 2014 2:50:05 PM UTC+1, Bill Wortinger wrote:
> 
> > Hello Dan, thanks again for all the help but I can't seem to get anything  
> > to return. Here is my full code, there has to be something I'm missing.  
> > Maybe in the indexing, the mapping?
> > 
> > Mapping:  
> > putMappingResponse = new PutMappingRequestBuilder(newClient  
> > .admin().indices())  
> > .setIndices(INDEX\_NAME)  
> > .setType(INDEX\_TYPE)  
> > .setSource(jsonBuilder().startObject("suggest")  
> > .field("type", "completion")  
> > .endObject().execute().actionGet());
> > 
> > Method:  
> > public String searchSuggestions(String suggestion) {  
> > // Creates suggestions based on Document Titles.  
> > String toReturn = "";
> > 
> > Client localClient = getElasticSearchClient();
> > 
> > CompletionSuggestionBuilder compBuilder = new  
> > CompletionSuggestionBuilder("completion");  
> > compBuilder.text(suggestion);  
> > compBuilder.field("suggest");
> > 
> > SuggestRequestBuilder suggestRequestBuilder = localClient  
> > .prepareSuggest(INDEX\_NAME).addSuggestion(compBuilder);
> > 
> > SuggestResponse suggestResponse =  
> > suggestRequestBuilder.execute().actionGet();  
> > CompletionSuggestion compSuggestion =  
> > suggestResponse.getSuggest().getSuggestion("completion");
> > 
> > List\<CompletionSuggestion.Entry\> entryList = compSuggestion.getEntries();  
> > if (entryList != null) {  
> > CompletionSuggestion.Entry entry = entryList.get(0);  
> > List\<CompletionSuggestion.Entry.Option\> options = entry.getOptions();  
> > if (options != null) {  
> > CompletionSuggestion.Entry.Option option = options.get(0);  
> > toReturn = option.getText().string();  
> > }  
> > }  
> > return toReturn;  
> > }
> > 
> > Index:  
> > response = localClient.prepareIndex(INDEX\_NAME, INDEX\_TYPE)
> > 
> > .setSource(jsonBuilder().startObject("suggest").field("input","FooFighters").endObject()).execute().actionGet();
> > 
> > Thanks for all the help, I'm basically shooting in the dark hoping  
> > somebody with more experience can spot the issue.
> > 
> > On Wed, Apr 9, 2014 at 3:56 AM, Dan Tuffery [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > 
> > > This looks wrong,
> > > 
> > > _Suggest.Suggestion.Entry.Option option2 =  
> > > suggestResponse.getSuggest().getSuggestion("completion").getEntries().get(0).getOptions().get(0);_
> > > 
> > > it should be:
> > > 
> > > \*Suggest.Suggestion.Entry.Option option2 = \*  
> > > _suggestResponse.getSuggest().getSuggestion("suggest").getEntries().get(0).getOptions().get(0);_
> > > 
> > > Where _getSuggestion_ is getting the field name you supplied in the  
> > > request.
> > > 
> > > Dan
> > > 
> > > So it looks like your query is returning zero results. Can you see  
> > > values indexed for the field 'at'
> > > 
> > > On Tuesday, April 8, 2014 4:07:57 PM UTC+1, Bill Wortinger wrote:
> > > 
> > > > Great resource! Thank you,
> > > > 
> > > > _CompletionSuggestionBuilder compBuilder = new  
> > > > CompletionSuggestionBuilder("completion");  
> > > > compBuilder.text(suggestion); compBuilder.field("suggest");  
> > > > SuggestRequestBuilder suggestRequestBuilder =  
> > > > localClient.prepareSuggest(INDEX\_NAME)  
> > > > .addSuggestion(compBuilder); SuggestResponse suggestResponse  
> > > > = suggestRequestBuilder.execute().actionGet();_
> > > > 
> > > > When executing
> > > > 
> > > > _Suggest.Suggestion.Entry.Option option2 =  
> > > > suggestResponse.getSuggest().getSuggestion("completion").getEntries().get(0).getOptions().get(0);_  
> > > > A null is returned.
> > > > 
> > > > Below is my index.
> > > > 
> > > > _.startObject("suggest").field("type", "completion").endObject()_
> > > > 
> > > > Thanks again!
> > > > 
> > > > On Tue, Apr 8, 2014 at 9:14 AM, Dan [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > > 
> > > > > What is the issue you're seeing? Have a look at the examples in the  
> > > > > tests:
> > > > > 
> > > > > [GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine](https://github.com/elasticsearch/elasticsearch/)  
> > > > > blob/master/src/test/java/org/elasticsearch/search/suggest/  
> > > > > CompletionSuggestSearchTests.java
> > > > > 
> > > > > Dan
> > > > > 
> > > > > On Tuesday, April 8, 2014 1:43:29 PM UTC+1, Bill Wortinger wrote:
> > > > > 
> > > > > > Thanks for the heads up Alex, I'll remove the .setTypes().
> > > > > > 
> > > > > > Dan, this is what I have so far;
> > > > > > 
> > > > > > CompletionSuggestionBuilder compBuilder = new  
> > > > > > CompletionSuggestionBuilder("complete");  
> > > > > > compBuilder.text('n");  
> > > > > > compBuilder.field("suggest");  
> > > > > > SuggestRequestBuilder suggestRequestBuilder =  
> > > > > > client.prepareSuggest(INDEX\_NAME);  
> > > > > > suggestRequestBuilder.addSuggestion(compBuilder);  
> > > > > > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > > > > > ).actionGet();
> > > > > > 
> > > > > > CompletionSuggestion compSuggestion = suggestResponse.getSuggest().g  
> > > > > > etSuggestion("complete");
> > > > > > 
> > > > > > List\<CompletionSuggestion.Entry\> entryList =  
> > > > > > compSuggestion.getEntries();  
> > > > > > if(entryList != null) {  
> > > > > > CompletionSuggestion.Entry entry = entryList.get(0);  
> > > > > > List\<CompletionSuggestion.Entry.Option\> options  
> > > > > > =entry.getOptions();  
> > > > > > if(options != null) {  
> > > > > > CompletionSuggestion.Entry.Option option =  
> > > > > > options.get(0);  
> > > > > > toReturn = option.getText().string();  
> > > > > > }  
> > > > > > }  
> > > > > > return toReturn;
> > > > > > 
> > > > > > I've made progress! But now it's falling apart when I try parsing the  
> > > > > > entries from the suggestReponse. So, am I doing this correctly? Missing  
> > > > > > something?
> > > > > > 
> > > > > > Thanks!
> > > > > > 
> > > > > > > 
> > > > > > 
> > > > > > On Monday, April 7, 2014 6:26:37 AM UTC-4, Dan wrote:
> > > > > > 
> > > > > > > Use the SuggestRequestBuilder, i.e.
> > > > > > > 
> > > > > > > CompletionSuggestionBuilder compBuilder = new  
> > > > > > > CompletionSuggestionBuilder("complete");  
> > > > > > > compBuilder.text("n");  
> > > > > > > compBuilder.field("suggest");
> > > > > > > 
> > > > > > > SuggestRequestBuilder suggestRequestBuilder =  
> > > > > > > client.prepareSuggest(INDEX\_NAME);  
> > > > > > > suggestRequestBuilder.addSuggestion(compBuilder);  
> > > > > > > SuggestResponse suggestResponse = suggestRequestBuilder.execute(  
> > > > > > > ).actionGet();
> > > > > > > 
> > > > > > > Dan
> > > > > > > 
> > > > > > > On Mon, Apr 7, 2014 at 8:49 AM, Alexander Reelsen \<[a...@spinscale.de](mailto:a...@spinscale.de)
> > > > > > > 
> > > > > > > > wrote:
> > > > > > > 
> > > > > > > > Hey,
> > > > > > > > 
> > > > > > > > looks ok. Minor note: Types are simply ignored for suggestions.  
> > > > > > > > What are you getting back? Nothing?  
> > > > > > > > Can you create a fully working gist, including creation of the  
> > > > > > > > mapping and indexing? Then debugging and finding your possible cause would  
> > > > > > > > be a lot easier.
> > > > > > > > 
> > > > > > > > --Alex
> > > > > > > > 
> > > > > > > > On Fri, Apr 4, 2014 at 4:02 PM, Bill Wortinger [r3dr...@gmail.com](mailto:r3dr...@gmail.com)wrote:
> > > > > > > > 
> > > > > > > > > I have my indices created, and mapping type for my 'suggest' field  
> > > > > > > > > set to completion. I can't figure out how to configure the query for  
> > > > > > > > > completion suggestions in elastic-search (Java API).
> > > > > > > > > 
> > > > > > > > > I'm trying to use this Query to base my implementation off of. "song-suggest" : { "text" : "n", "completion" : { "field" : "suggest" } } Here's  
> > > > > > > > > what I have so far,
> > > > > > > > > 
> > > > > > > > > ```
> > > > > > > > > CompletionSuggestionBuilder compBuilder = new CompletionSuggestionBuilder("complete"); 
> > > > > > > > > compBuilder.text("n..");
> > > > > > > > > compBuilder.field("suggest");
> > > > > > > > > 
> > > > > > > > > SearchResponse searchResponse = localClient.prepareSearch(INDEX_NAME)
> > > > > > > > > .setTypes("completion")
> > > > > > > > > .setQuery(QueryBuilders.matchAllQuery())
> > > > > > > > > .addSuggestion(compBuilder)
> > > > > > > > > .execute().actionGet();
> > > > > > > > > 
> > > > > > > > > CompletionSuggestion compSuggestion = searchResponse.getSuggest().getSuggestion("complete");
> > > > > > > > > 
> > > > > > > > > ```
> > > > > > > > > 
> > > > > > > > > Am I missing something, doing something wrong? Thanks!
> > > > > > > > > 
> > > > > > > > > --  
> > > > > > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > > > > To view this discussion on the web visit  
> > > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/06792c37-646](https://groups.google.com/d/msgid/elasticsearch/06792c37-646)  
> > > > > > > > > c-4b59-bdb3-f23cc51bd134%[40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/06792c37-646c-4b59-bdb3-f23cc51bd134%40googlegroups.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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > > > To view this discussion on the web visit  
> > > > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76G](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76G)  
> > > > > > > > mrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%[40mail.gmail.com](http://40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9D76GmrXqdnBy%3DkstCN4NDtfkS3X%3DyXd0uMdTVpSUBvg%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 a topic in the  
> > > > > > > Google Groups "elasticsearch" group.  
> > > > > > > To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > > > topic/elasticsearch/06nbxJnYfDo/unsubscribe.  
> > > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > > > msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%  
> > > > > > > [40googlegroups.com](http://40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f6e28fc8-cef5-4f13-8dce-04e0bcfc5404%40googlegroups.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 a topic in the  
> > > > Google Groups "elasticsearch" group.  
> > > > To unsubscribe from this topic, visit  
> > > > [https://groups.google.com/d/topic/elasticsearch/06nbxJnYfDo/unsubscribe](https://groups.google.com/d/topic/elasticsearch/06nbxJnYfDo/unsubscribe).  
> > > > To unsubscribe from this group and all its topics, send an email to  
> > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit  
> > > > [https://groups.google.com/d/msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/6fa70b40-0fb7-4735-851d-bf8bc872fd38%40googlegroups.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/e1675de0-6c43-4a8e-b2d3-e73f41d8bebf%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e1675de0-6c43-4a8e-b2d3-e73f41d8bebf%40googlegroups.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, 1:32am UTC](https://discuss.elastic.co/t/querying-with-completion-suggesters-with-java-api/16822/15 "2017-07-06T01:32:59Z")

</div>


