# Phrase suggester collate query in java api

**URL:** <https://discuss.elastic.co/t/phrase-suggester-collate-query-in-java-api/139014>\
**Category:** Elasticsearch\
**Created:** [July 7, 2018, 12:39pm UTC](https://discuss.elastic.co/t/phrase-suggester-collate-query-in-java-api/139014 "2018-07-07T12:39:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NarimanN2](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@NarimanN2](https://discuss.elastic.co/u/NarimanN2)\
**Post date:** [July 7, 2018, 12:39pm UTC](https://discuss.elastic.co/t/phrase-suggester-collate-query-in-java-api/139014/1 "2018-07-07T12:39:02Z")

</div>

The PhraseSuggestionBuilder in elasticsearch java API has a collateQuery method that takes a String as input. but there is a problem, this code:

> collateQuery("\"match\": {\"title.phrase\" : \"{{suggestion}}\"}")

will result in something like this:

> "collate" : {  
> "query" : "\"match\": {\"title\" : \"{{suggeston}}\"}"  
> }

as you see the escaped quotes are still there and I get "failed to derive xcontent" error. I can not find an example of collateQuery using java api. what should I do?

---

<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:** [August 4, 2018, 12:41pm UTC](https://discuss.elastic.co/t/phrase-suggester-collate-query-in-java-api/139014/2 "2018-08-04T12:41:20Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
