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 <[email protected]> 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 <[email protected]> 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 [email protected].
>> 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?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit 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 [email protected].
> 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?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CAEyth3vRqny8v67fY925TYkd23FnfvAW6mmzobFA1jVv66BCHw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to