# Re: Issue with phrase\_prefix query for the \_id field

**URL:** <https://discuss.elastic.co/t/re-issue-with-phrase-prefix-query-for-the--id-field/19506>\
**Category:** Elasticsearch\
**Created:** [August 28, 2014, 9:05am UTC](https://discuss.elastic.co/t/re-issue-with-phrase-prefix-query-for-the--id-field/19506 "2014-08-28T09:05:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ajinkya\_Apte](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@Ajinkya\_Apte](https://discuss.elastic.co/u/Ajinkya_Apte)\
**Post date:** [August 28, 2014, 9:05am UTC](https://discuss.elastic.co/t/re-issue-with-phrase-prefix-query-for-the--id-field/19506/1 "2014-08-28T09:05:17Z")

</div>

Hello,  
I am having some trouble with getting the phrase\_prefix search working with  
the \_id field. Here is my example:

#Reset the index  
DELETE /profile-101

#Mapping creation  
PUT /profile-101  
{  
"mappings": {  
"profile": {  
"properties": {  
"full-name" : {  
"type": "string"  
}  
}  
}  
}  
}

#Document creation  
POST /profile-101/profile/nickname/  
{  
"full-name" : "Ajinkya Apte"  
}

_Issue:_

1. When I do:  
GET /profile-101/profile/\_search  
{  
"query" : {  
"match" : {  
"full-name" : {  
"query" : "Ajin",  
"type" : "phrase\_prefix"  
}  
}  
}  
}  
I get the result correctly;

However when I do something similar for the \_id field it does not work

GET /profile-101/profile/\_search  
{  
"query" : {  
"match" : {  
"\_id" : {  
"query" : "nic",  
"type" : "phrase\_prefix"  
}  
}  
}  
}

I am probably missing something here, can someone please point me in the  
right direction?  
I eventually want to combine the two queries using multi\_match but first  
want to figure out the correct way to run a phrase\_prefix query on the \_id  
field:  
GET /profile-101/profile/\_search  
{  
"query" : {  
"multi\_match" : {  
"query": "User query",  
"type": "phrase\_prefix",  
"fields": ["\_id", "full-name"],  
"tie\_breaker": 0.3  
}  
}  
}

Thanks,  
AJ

--  
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/fafb6209-626a-4dfd-a1a7-121e8e8e38b6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fafb6209-626a-4dfd-a1a7-121e8e8e38b6%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ajinkya\_Apte](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@Ajinkya\_Apte](https://discuss.elastic.co/u/Ajinkya_Apte)\
**Post date:** [August 28, 2014, 9:01pm UTC](https://discuss.elastic.co/t/re-issue-with-phrase-prefix-query-for-the--id-field/19506/2 "2014-08-28T21:01:52Z")

</div>

Can anyone help me please?

AJ

On Thursday, August 28, 2014 2:05:18 AM UTC-7, Ajinkya Apte wrote:

> Hello,  
> I am having some trouble with getting the phrase\_prefix search working  
> with the \_id field. Here is my example:
> 
> #Reset the index  
> DELETE /profile-101
> 
> #Mapping creation  
> PUT /profile-101  
> {  
> "mappings": {  
> "profile": {  
> "properties": {  
> "full-name" : {  
> "type": "string"  
> }  
> }  
> }  
> }  
> }
> 
> #Document creation  
> POST /profile-101/profile/nickname/  
> {  
> "full-name" : "Ajinkya Apte"  
> }
> 
> _Issue:_
> 
> 1. When I do:  
> GET /profile-101/profile/\_search  
> {  
> "query" : {  
> "match" : {  
> "full-name" : {  
> "query" : "Ajin",  
> "type" : "phrase\_prefix"  
> }  
> }  
> }  
> }  
> I get the result correctly;
> 
> However when I do something similar for the \_id field it does not work
> 
> GET /profile-101/profile/\_search  
> {  
> "query" : {  
> "match" : {  
> "\_id" : {  
> "query" : "nic",  
> "type" : "phrase\_prefix"  
> }  
> }  
> }  
> }
> 
> I am probably missing something here, can someone please point me in the  
> right direction?  
> I eventually want to combine the two queries using multi\_match but first  
> want to figure out the correct way to run a phrase\_prefix query on the \_id  
> field:  
> GET /profile-101/profile/\_search  
> {  
> "query" : {  
> "multi\_match" : {  
> "query": "User query",  
> "type": "phrase\_prefix",  
> "fields": ["\_id", "full-name"],  
> "tie\_breaker": 0.3  
> }  
> }  
> }
> 
> Thanks,  
> AJ

--  
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/2f1b9e8b-1c75-4ad3-a6dd-a3fd528eea09%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2f1b9e8b-1c75-4ad3-a6dd-a3fd528eea09%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:05am UTC](https://discuss.elastic.co/t/re-issue-with-phrase-prefix-query-for-the--id-field/19506/3 "2017-07-06T01:05:36Z")

</div>


