# Match\_phrase\_prefix Java API

**URL:** <https://discuss.elastic.co/t/match-phrase-prefix-java-api/23751>\
**Category:** Elasticsearch\
**Created:** [June 5, 2015, 1:10pm UTC](https://discuss.elastic.co/t/match-phrase-prefix-java-api/23751 "2015-06-05T13:10:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anusha](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@Anusha](https://discuss.elastic.co/u/Anusha)\
**Post date:** [June 5, 2015, 1:10pm UTC](https://discuss.elastic.co/t/match-phrase-prefix-java-api/23751/1 "2015-06-05T13:10:47Z")

</div>

Hi,

I would like to get the relevant JAVA API for the Query,

GET sayt/othermotive/\_search  
{  
"query": {  
"bool": {  
"must": [  
{  
"match": {  
"yearCode": {  
"query": "2012",  
"type": "boolean"  
}  
}  
}, {  
"match" : {  
"modelCode" : {  
"query" : "1",  
"type" : "boolean"  
}  
}  
}, {  
"match" : {  
"engineCode" : {  
"query" : "12",  
"type" : "boolean"  
}  
}  
}, {  
"term" : {  
"makeTypeCode" : "3"  
}  
},  
{

_"match\_phrase\_prefix": {  
"partDescription":"a" }_  
}  
]  
}  
}  
}

Am using a Java API as shown below:

_builder.must(QueryBuilders.matchPhrasePrefixQuery("partDescription",  
term));_

But this is building the query as

{  
"query" : {  
"bool" : {  
"must" : [ {  
"match" : {  
"yearCode" : {  
"query" : "2012",  
"type" : "boolean"  
}  
}  
}, {  
"match" : {  
"makeCode" : {  
"query" : "143",  
"type" : "boolean"  
}  
}  
}, {  
"match" : {  
"modelCode" : {  
"query" : "1",  
"type" : "boolean"  
}  
}  
}, {  
"match" : {  
"engineCode" : {  
"query" : "12",  
"type" : "boolean"  
}  
}  
}, {  
"term" : {  
"makeTypeCode" : "3"  
}  
}, {

_"match" : { "partDescription" : { "query" :  
"ac", "type" : "phrase\_prefix" }_  
}  
} ]  
}  
}  
}

When I use this query am not getting result, When am using the query as I  
mention above with \*match\_phrase\_prefix \*it is giving the result

May I know the relevant Java API for match\_phrase\_prefix...

## -- Please update your bookmarks! We have moved to [https://discuss.elastic.co/](https://discuss.elastic.co/)

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/1e008776-21db-4875-9b8a-ba58bfdf6f83%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1e008776-21db-4875-9b8a-ba58bfdf6f83%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, 12:09am UTC](https://discuss.elastic.co/t/match-phrase-prefix-java-api/23751/2 "2017-07-06T00:09:24Z")

</div>

Closed on July 6, 2017, 12:09am UTC


