# Suggestion query using the SearchRequestBuilder

**URL:** <https://discuss.elastic.co/t/suggestion-query-using-the-searchrequestbuilder/11906>\
**Category:** Elasticsearch\
**Created:** [May 9, 2013, 8:00pm UTC](https://discuss.elastic.co/t/suggestion-query-using-the-searchrequestbuilder/11906 "2013-05-09T20:00:41Z")\
**Posts on this page:** 4\
**Page:** 1

<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:** [May 9, 2013, 8:00pm UTC](https://discuss.elastic.co/t/suggestion-query-using-the-searchrequestbuilder/11906/1 "2013-05-09T20:00:41Z")

</div>

I need to add suggest queries along with my main query. I'm using the Java  
API and the SearchRequestBuilder.

Is there a way to add the suggestion query to the SearchRequestBuilder  
query?

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [May 9, 2013, 9:00pm UTC](https://discuss.elastic.co/t/suggestion-query-using-the-searchrequestbuilder/11906/2 "2013-05-09T21:00:44Z")

</div>

I've found the SuggestBuilder class, can anyone shed some light how I can  
add the SuggestBuilder object to my query?

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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [May 10, 2013, 2:07am UTC](https://discuss.elastic.co/t/suggestion-query-using-the-searchrequestbuilder/11906/3 "2013-05-10T02:07:30Z")

</div>

The suggest API is only available in 0.90+. I have never tried it, but  
according to the source, you add a SuggestBuilder to a SearchRequestBuilder  
via the addSuggestion method:

[https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java#L662](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java#L662)

--  
Ivan

On Thu, May 9, 2013 at 2:00 PM, es newbie [dan.tuffery@gmail.com](mailto:dan.tuffery@gmail.com) wrote:

> I've found the SuggestBuilder class, can anyone shed some light how I can  
> add the SuggestBuilder object to my query?
> 
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:37am UTC](https://discuss.elastic.co/t/suggestion-query-using-the-searchrequestbuilder/11906/4 "2017-07-06T02:37:14Z")

</div>


