# Duplicated \_id returned as list

**URL:** <https://discuss.elastic.co/t/duplicated--id-returned-as-list/8697>\
**Category:** Elasticsearch\
**Created:** [August 9, 2012, 9:38pm UTC](https://discuss.elastic.co/t/duplicated--id-returned-as-list/8697 "2012-08-09T21:38:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![roger\_2](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@roger\_2](https://discuss.elastic.co/u/roger_2)\
**Post date:** [August 9, 2012, 9:38pm UTC](https://discuss.elastic.co/t/duplicated--id-returned-as-list/8697/1 "2012-08-09T21:38:29Z")

</div>

Hi,

the following query returns the \_id twice as list instead of the single \_id  
in fields

{  
"query": {  
"text\_phrase\_prefix": {  
"aSearchName": {  
"max\_expansions": 10,  
"analyzer": "default",  
"query": "recruiter"  
}  
}  
},  
"fields": [  
"\_id",  
"aSearchName"  
]  
}

The result from my elasticsearch connection  
and also elastichead looks like:

{

```
took: 9
timed_out: false
_shards: {
    total: 7
    successful: 7
    failed: 0
}
hits: {
    total: 1
    max_score: 0.9297228
    hits: [
        {
            _index: members
            _type: member
            _id: 501fc7117a93312324008d9f
            _score: 0.9297228
            fields: {
                _id: [
                    501fc7117a93312324008d9f
                    501fc7117a93312324008d9f
                ]
                aSearchName: Recruiter RECRUITER, Bern
            }
        }
    ]
}

```

}

The index mapping defines:  
"\_id": {"store": "yes"}

The elasticserver version is 0.19.4

Is this a known issue and solved in newer versions?

Mit freundlichem Gruss  
Roger Ineichen

* * *

Projekt01 GmbH  
www.projekt01.ch  
Boesch 65  
6331 Hünenberg  
phone +41 (0)41 781 01 78  
mobile +41 (0)79 340 52 32  
fax +41 (0)41 781 00 78  
email roger.ineichen@projekt01.ch

* * *

END OF MESSAGE

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [August 10, 2012, 1:31am UTC](https://discuss.elastic.co/t/duplicated--id-returned-as-list/8697/2 "2012-08-10T01:31:19Z")

</div>

I just tried it with master and it still works this way. Here is repro

- [Repro for double id problem · GitHub](https://gist.github.com/3309993)

A possible workaround is to remove "\_id" field from the source of the  
document.

On Thursday, August 9, 2012 5:38:29 PM UTC-4, projekt01 wrote:

> Hi,
> 
> the following query returns the \_id twice as list instead of the single  
> \_id  
> in fields
> 
> {  
> "query": {  
> "text\_phrase\_prefix": {  
> "aSearchName": {  
> "max\_expansions": 10,  
> "analyzer": "default",  
> "query": "recruiter"  
> }  
> }  
> },  
> "fields": [  
> "\_id",  
> "aSearchName"  
> ]  
> }
> 
> The result from my elasticsearch connection  
> and also elastichead looks like:
> 
> {
> 
> ```
> took: 9 
> timed_out: false 
> _shards: { 
> total: 7 
> successful: 7 
> failed: 0 
> } 
> hits: { 
> total: 1 
> max_score: 0.9297228 
> hits: [ 
> { 
> _index: members 
> _type: member 
> _id: 501fc7117a93312324008d9f 
> _score: 0.9297228 
> fields: { 
> _id: [ 
> 501fc7117a93312324008d9f 
> 501fc7117a93312324008d9f 
> ] 
> aSearchName: Recruiter RECRUITER, Bern 
> } 
> } 
> ] 
> } 
> 
> ```
> 
> }
> 
> The index mapping defines:  
> "\_id": {"store": "yes"}
> 
> The elasticserver version is 0.19.4
> 
> Is this a known issue and solved in newer versions?
> 
> Mit freundlichem Gruss  
> Roger Ineichen
> 
> * * *
> 
> Projekt01 GmbH  
> www.projekt01.ch  
> Boesch 65  
> 6331 Hünenberg  
> phone +41 (0)41 781 01 78  
> mobile +41 (0)79 340 52 32  
> fax +41 (0)41 781 00 78  
> email roger.i...@projekt01.ch \<javascript:\>
> 
> * * *
> 
> END OF MESSAGE

---

<div class="post-metadata">

**Author:** ![roger\_2](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@roger\_2](https://discuss.elastic.co/u/roger_2)\
**Post date:** [August 10, 2012, 1:05pm UTC](https://discuss.elastic.co/t/duplicated--id-returned-as-list/8697/3 "2012-08-10T13:05:25Z")

</div>

Hi Igor,

> Betreff: Re: duplicated \_id returned as list
> 
> I just tried it with master and it still works this way. Here is repro -  
> [Repro for double id problem · GitHub](https://gist.github.com/3309993)
> 
> A possible workaround is to remove "\_id" field from the source of the document.

Ah thanks, didn't think about that. I was using the \_id directly from the hits dict  
as a workarround.

Can you add an issue with you gist sample or should I add one?

Regards  
Roger Ineichen

> On Thursday, August 9, 2012 5:38:29 PM UTC-4, projekt01 wrote:
> 
> Hi,
> 
> the following query returns the \_id twice as list instead of the single \_id  
> in fields
> 
> {  
> "query": {  
> "text\_phrase\_prefix": {  
> "aSearchName": {  
> "max\_expansions": 10,  
> "analyzer": "default",  
> "query": "recruiter"  
> }  
> }  
> },  
> "fields": [  
> "\_id",  
> "aSearchName"  
> ]  
> }
> 
> The result from my elasticsearch connection  
> and also elastichead looks like:
> 
> {
> 
> ```
> took: 9
> timed_out: false
> _shards: {
> total: 7
> successful: 7
> failed: 0
> }
> hits: {
> total: 1
> max_score: 0.9297228
> hits: [
> {
> _index: members
> _type: member
> _id: 501fc7117a93312324008d9f
> _score: 0.9297228
> fields: {
> _id: [
> 501fc7117a93312324008d9f
> 501fc7117a93312324008d9f
> ]
> aSearchName: Recruiter RECRUITER, Bern
> }
> }
> ]
> }
> 
> ```
> 
> }
> 
> The index mapping defines:  
> "\_id": {"store": "yes"}
> 
> The elasticserver version is 0.19.4
> 
> Is this a known issue and solved in newer versions?
> 
> Mit freundlichem Gruss  
> Roger Ineichen
> 
> * * *
> 
> Projekt01 GmbH  
> www.projekt01.ch  
> Boesch 65  
> 6331 Hünenberg  
> phone +41 (0)41 781 01 78  
> mobile +41 (0)79 340 52 32  
> fax +41 (0)41 781 00 78  
> email roger.i...@projekt01.ch \<javascript:\>
> 
> * * *
> 
> END OF MESSAGE

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [August 10, 2012, 1:49pm UTC](https://discuss.elastic.co/t/duplicated--id-returned-as-list/8697/4 "2012-08-10T13:49:53Z")

</div>

Created [When \_id field is stored and is present in the source, it is returned twice in the list of fields · Issue #2161 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2161)

On Friday, August 10, 2012 9:05:25 AM UTC-4, projekt01 wrote:

> Hi Igor,
> 
> > Betreff: Re: duplicated \_id returned as list
> > 
> > I just tried it with master and it still works this way. Here is repro -  
> > [Repro for double id problem · GitHub](https://gist.github.com/3309993)
> > 
> > A possible workaround is to remove "\_id" field from the source of the  
> > document.
> 
> Ah thanks, didn't think about that. I was using the \_id directly from the  
> hits dict  
> as a workarround.
> 
> Can you add an issue with you gist sample or should I add one?
> 
> Regards  
> Roger Ineichen
> 
> > On Thursday, August 9, 2012 5:38:29 PM UTC-4, projekt01 wrote:
> > 
> > ```
> > Hi, 
> > 
> > the following query returns the _id twice as list instead of the 
> > 
> > ```
> 
> single \_id
> 
> > ```
> > in fields 
> > 
> > { 
> > "query": { 
> > "text_phrase_prefix": { 
> > "aSearchName": { 
> > "max_expansions": 10, 
> > "analyzer": "default", 
> > "query": "recruiter" 
> > } 
> > } 
> > }, 
> > "fields": [ 
> > "_id", 
> > "aSearchName" 
> > ] 
> > } 
> > 
> > The result from my elasticsearch connection 
> > and also elastichead looks like: 
> > 
> > { 
> > 
> > took: 9 
> > timed_out: false 
> > _shards: { 
> > total: 7 
> > successful: 7 
> > failed: 0 
> > } 
> > hits: { 
> > total: 1 
> > max_score: 0.9297228 
> > hits: [ 
> > { 
> > _index: members 
> > _type: member 
> > _id: 501fc7117a93312324008d9f 
> > _score: 0.9297228 
> > fields: { 
> > _id: [ 
> > 501fc7117a93312324008d9f 
> > 501fc7117a93312324008d9f 
> > ] 
> > aSearchName: Recruiter RECRUITER, Bern 
> > } 
> > } 
> > ] 
> > } 
> > 
> > } 
> > 
> > The index mapping defines: 
> > "_id": {"store": "yes"} 
> > 
> > The elasticserver version is 0.19.4 
> > 
> > Is this a known issue and solved in newer versions? 
> > 
> > Mit freundlichem Gruss 
> > Roger Ineichen 
> > _____________________________ 
> > Projekt01 GmbH 
> > www.projekt01.ch 
> > Boesch 65 
> > 6331 Hünenberg 
> > phone +41 (0)41 781 01 78 
> > mobile +41 (0)79 340 52 32 
> > fax +41 (0)41 781 00 78 
> > email roger.i...@projekt01.ch <javascript:> 
> > _____________________________ 
> > END OF MESSAGE 
> > 
> > ```

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 13, 2012, 11:11am UTC](https://discuss.elastic.co/t/duplicated--id-returned-as-list/8697/5 "2012-08-13T11:11:50Z")

</div>

There isn't really a reason to store the \_id, as its already stored as part  
of the internal \_uid and you always get it back as part of a hit response.  
We should probably simply not allow to set store on the \_id mapping.

On Friday, August 10, 2012 3:49:53 PM UTC+2, Igor Motov wrote:

> Created [When \_id field is stored and is present in the source, it is returned twice in the list of fields · Issue #2161 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2161)
> 
> On Friday, August 10, 2012 9:05:25 AM UTC-4, projekt01 wrote:
> 
> > Hi Igor,
> > 
> > > Betreff: Re: duplicated \_id returned as list
> > > 
> > > I just tried it with master and it still works this way. Here is repro
> > 
> > - 
> > 
> > > [Repro for double id problem · GitHub](https://gist.github.com/3309993)
> > > 
> > > A possible workaround is to remove "\_id" field from the source of the  
> > > document.
> > 
> > Ah thanks, didn't think about that. I was using the \_id directly from the  
> > hits dict  
> > as a workarround.
> > 
> > Can you add an issue with you gist sample or should I add one?
> > 
> > Regards  
> > Roger Ineichen
> > 
> > > On Thursday, August 9, 2012 5:38:29 PM UTC-4, projekt01 wrote:
> > > 
> > > ```
> > > Hi, 
> > > 
> > > the following query returns the _id twice as list instead of 
> > > 
> > > ```
> > 
> > the single \_id
> > 
> > > ```
> > > in fields 
> > > 
> > > { 
> > > "query": { 
> > > "text_phrase_prefix": { 
> > > "aSearchName": { 
> > > "max_expansions": 10, 
> > > "analyzer": "default", 
> > > "query": "recruiter" 
> > > } 
> > > } 
> > > }, 
> > > "fields": [ 
> > > "_id", 
> > > "aSearchName" 
> > > ] 
> > > } 
> > > 
> > > The result from my elasticsearch connection 
> > > and also elastichead looks like: 
> > > 
> > > { 
> > > 
> > > took: 9 
> > > timed_out: false 
> > > _shards: { 
> > > total: 7 
> > > successful: 7 
> > > failed: 0 
> > > } 
> > > hits: { 
> > > total: 1 
> > > max_score: 0.9297228 
> > > hits: [ 
> > > { 
> > > _index: members 
> > > _type: member 
> > > _id: 501fc7117a93312324008d9f 
> > > _score: 0.9297228 
> > > fields: { 
> > > _id: [ 
> > > 501fc7117a93312324008d9f 
> > > 501fc7117a93312324008d9f 
> > > ] 
> > > aSearchName: Recruiter RECRUITER, Bern 
> > > } 
> > > } 
> > > ] 
> > > } 
> > > 
> > > } 
> > > 
> > > The index mapping defines: 
> > > "_id": {"store": "yes"} 
> > > 
> > > The elasticserver version is 0.19.4 
> > > 
> > > Is this a known issue and solved in newer versions? 
> > > 
> > > Mit freundlichem Gruss 
> > > Roger Ineichen 
> > > _____________________________ 
> > > Projekt01 GmbH 
> > > www.projekt01.ch 
> > > Boesch 65 
> > > 6331 Hünenberg 
> > > phone +41 (0)41 781 01 78 
> > > mobile +41 (0)79 340 52 32 
> > > fax +41 (0)41 781 00 78 
> > > email roger.i...@projekt01.ch <javascript:> 
> > > _____________________________ 
> > > END OF MESSAGE 
> > > 
> > > ```

--

---

<div class="post-metadata">

**Author:** ![roger\_2](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@roger\_2](https://discuss.elastic.co/u/roger_2)\
**Post date:** [August 13, 2012, 1:26pm UTC](https://discuss.elastic.co/t/duplicated--id-returned-as-list/8697/6 "2012-08-13T13:26:50Z")

</div>

Hi kimchy

> Betreff: Re: duplicated \_id returned as list
> 
> There isn't really a reason to store the \_id, as its already stored as  
> part of the internal  
> \_uid and you always get it back as part of a hit response. We should  
> probably simply  
> not allow to set store on the \_id mapping.

I often use the hits['fields'] with the pyhton API. It is nice  
if the \_id key/value whould be a part of this fields. It makes it  
simpler to write code for data given from elasticsearch or mongodb.

Probably a good idea whould be not storing the \_id , but merge the\_id  
key/value  
into the fields result if asked for. This whould also be compatible with  
previous  
versions.

Regards  
Roger Ineichen

> On Friday, August 10, 2012 3:49:53 PM UTC+2, Igor Motov wrote:
> 
> Created [When \_id field is stored and is present in the source, it is returned twice in the list of fields · Issue #2161 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2161)  
> [https://github.com/elasticsearch/elasticsearch/issues/2161](https://github.com/elasticsearch/elasticsearch/issues/2161)
> 
> On Friday, August 10, 2012 9:05:25 AM UTC-4, projekt01 wrote:
> 
> ```
> Hi Igor,
> 
> > Betreff: Re: duplicated _id returned as list
> >
> > I just tried it with master and it still works this way.
> 
> ```

Here is repro -

> ```
> > https://gist.github.com/3309993
> 
> ```

[https://gist.github.com/3309993](https://gist.github.com/3309993)

> ```
> >
> > A possible workaround is to remove "_id" field from the
> 
> ```

source of the

> document.
> 
> ```
> Ah thanks, didn't think about that. I was using the _id
> 
> ```

directly from the

> hits dict  
> as a workarround.
> 
> ```
> Can you add an issue with you gist sample or should I add
> 
> ```

one?

> ```
> Regards
> Roger Ineichen
> 
> > On Thursday, August 9, 2012 5:38:29 PM UTC-4, projekt01
> 
> ```

wrote:

> ```
> >
> > Hi,
> >
> > the following query returns the _id twice as list
> 
> ```

instead of the

> single \_id  
> \> in fields  
> \>  
> \> {  
> \> "query": {  
> \> "text\_phrase\_prefix": {  
> \> "aSearchName": {  
> \> "max\_expansions": 10,  
> \> "analyzer": "default",  
> \> "query": "recruiter"  
> \> }  
> \> }  
> \> },  
> \> "fields": [  
> \> "\_id",  
> \> "aSearchName"  
> \> ]  
> \> }  
> \>  
> \> The result from my elasticsearch connection  
> \> and also elastichead looks like:  
> \>  
> \> {  
> \>  
> \> took: 9  
> \> timed\_out: false  
> \> \_shards: {  
> \> total: 7  
> \> successful: 7  
> \> failed: 0  
> \> }  
> \> hits: {  
> \> total: 1  
> \> max\_score: 0.9297228  
> \> hits: [  
> \> {  
> \> \_index: members  
> \> \_type: member  
> \> \_id: 501fc7117a93312324008d9f  
> \> \_score: 0.9297228  
> \> fields: {  
> \> \_id: [  
> \> 501fc7117a93312324008d9f  
> \> 501fc7117a93312324008d9f  
> \> ]  
> \> aSearchName: Recruiter  
> RECRUITER, Bern  
> \> }  
> \> }  
> \> ]  
> \> }  
> \>  
> \> }  
> \>  
> \> The index mapping defines:  
> \> "\_id": {"store": "yes"}  
> \>  
> \> The elasticserver version is 0.19.4  
> \>  
> \> Is this a known issue and solved in newer  
> versions?  
> \>  
> \>  
> \> Mit freundlichem Gruss  
> \> Roger Ineichen  
> \> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> \> Projekt01 GmbH  
> \> www.projekt01.ch  
> \> Boesch 65  
> \> 6331 Hünenberg  
> \> phone +41 (0)41 781 01 78  
> \> mobile +41 (0)79 340 52 32  
> \> fax +41 (0)41 781 00 78  
> \> email roger.i...@projekt01.ch \<javascript:\>  
> \> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> \> END OF MESSAGE  
> \>  
> \>  
> \>  
> \>  
> \>
> 
> --

--

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 13, 2012, 4:06pm UTC](https://discuss.elastic.co/t/duplicated--id-returned-as-list/8697/7 "2012-08-13T16:06:14Z")

</div>

Thats not the format of how elasticsearch works, the \_id has its own section, not within the fields.

On Aug 9, 2012, at 11:38 PM, Roger [dev@projekt01.ch](mailto:dev@projekt01.ch) wrote:

> Hi,
> 
> the following query returns the \_id twice as list instead of the single \_id  
> in fields
> 
> {  
> "query": {  
> "text\_phrase\_prefix": {  
> "aSearchName": {  
> "max\_expansions": 10,  
> "analyzer": "default",  
> "query": "recruiter"  
> }  
> }  
> },  
> "fields": [  
> "\_id",  
> "aSearchName"  
> ]  
> }
> 
> The result from my elasticsearch connection  
> and also elastichead looks like:
> 
> {
> 
> took: 9  
> timed\_out: false  
> \_shards: {  
> total: 7  
> successful: 7  
> failed: 0  
> }  
> hits: {  
> total: 1  
> max\_score: 0.9297228  
> hits: [  
> {  
> \_index: members  
> \_type: member  
> \_id: 501fc7117a93312324008d9f  
> \_score: 0.9297228  
> fields: {  
> \_id: [  
> 501fc7117a93312324008d9f  
> 501fc7117a93312324008d9f  
> ]  
> aSearchName: Recruiter RECRUITER, Bern  
> }  
> }  
> ]  
> }
> 
> }
> 
> The index mapping defines:  
> "\_id": {"store": "yes"}
> 
> The elasticserver version is 0.19.4
> 
> Is this a known issue and solved in newer versions?
> 
> Mit freundlichem Gruss  
> Roger Ineichen
> 
> * * *
> 
> Projekt01 GmbH  
> www.projekt01.ch  
> Boesch 65  
> 6331 Hünenberg  
> phone +41 (0)41 781 01 78  
> mobile +41 (0)79 340 52 32  
> fax +41 (0)41 781 00 78  
> email roger.ineichen@projekt01.ch
> 
> * * *
> 
> END OF MESSAGE

--

---

<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, 3:16am UTC](https://discuss.elastic.co/t/duplicated--id-returned-as-list/8697/8 "2017-07-06T03:16:33Z")

</div>


