# \_id field missing from the mapping?

**URL:** https://discuss.elastic.co/t/-id-field-missing-from-the-mapping/7254
**Category:** Elasticsearch
**Created:** [April 6, 2012, 7:15pm UTC](https://discuss.elastic.co/t/-id-field-missing-from-the-mapping/7254 "2012-04-06T19:15:36Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Andrius\_Juozapaitis](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@Andrius\_Juozapaitis](https://discuss.elastic.co/u/Andrius_Juozapaitis)
#### Post date: [April 6, 2012, 7:15pm UTC](https://discuss.elastic.co/t/-id-field-missing-from-the-mapping/7254/1 "2012-04-06T19:15:36Z")

</div>

Hey all,

I stumbled upon an issue with elasticsearch indexing couchdb documents: \_id  
field is indexed, but not added to the mapping, and hence the \_all field,  
so if I do a query\_string search, I have to specifically use the \_id:XXX123  
to find the specific document. I am most likely missing something obvious.  
Here's the mapping I am submitting to elasticsearch:

```auto
{"sp-type":{
    "properties":{
        "_id":{
            "store":"yes",
            "type":"string",
            "index":"not_analyzed"
        },
        "_rev":{
            "type":"string",
            "index":"not_analyzed"
        },
        "title":{
            "type":"string",
            "index":"not_analyzed"
        },
        "code":{
            "type":"string",
            "index":"not_analyzed"
        },
        "description":{
            "type":"string",
            "index":"not_analyzed"
        },
        "dataPriority":{
            "type":"long"
        },
        "specificationPriority":{
            "type":"long"
        },
        "mediaPriority":{
            "type":"long"
        }
    }
}}
```

and this is what's being returned when I look up the index metadata through  
elasticsearch-head:

```auto
{
    "state":"open",
    "settings":{
        "index.number_of_shards":5,
        "index.number_of_replicas":1,
        "index.version.created":200001
    },
    "mappings":{
        "sp-type":{
            "properties":{
                "_rev":{
                    "index":"not_analyzed",
                    "type":"string"
                },
                "title":{
                    "index":"not_analyzed",
                    "type":"string"
                },
                "specificationPriority":{
                    "type":"long"
                },
                "dataPriority":{
                    "type":"long"
                },
                "description":{
                    "index":"not_analyzed",
                    "type":"string"
                },
                "code":{
                    "index":"not_analyzed",
                    "type":"string"
                },
                "mediaPriority":{
                    "type":"long"
                }
            }
        }
    },
    "aliases":[]
}
```

Perhaps I am specifying in the wrong level of the mapping document?  
Essentially, I would be happy if the \_id field would somehow make it into  
the \_all field.

regards,  
Andrius Juozapaitis

---

<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: [April 7, 2012, 3:20pm UTC](https://discuss.elastic.co/t/-id-field-missing-from-the-mapping/7254/2 "2012-04-07T15:20:31Z")

</div>

You are not placing the \_id mapping in the correct place, it should be on  
the same level as the top most properties, and not within properties, see  
more here:  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/id-field.html).

On Fri, Apr 6, 2012 at 10:15 PM, Andrius Juozapaitis [andriusj@gmail.com](mailto:andriusj@gmail.com)wrote:

> Hey all,
> 
> I stumbled upon an issue with elasticsearch indexing couchdb documents:  
> \_id field is indexed, but not added to the mapping, and hence the \_all  
> field, so if I do a query\_string search, I have to specifically use the  
> \_id:XXX123 to find the specific document. I am most likely missing  
> something obvious. Here's the mapping I am submitting to elasticsearch:
> 
> ```auto
> {"sp-type":{
> > "properties":{
> > "_id":{
> > "store":"yes",
> > "type":"string",
> > "index":"not_analyzed"
> > },
> > "_rev":{
> > "type":"string",
> > "index":"not_analyzed"
> > },
> > "title":{
> > "type":"string",
> > "index":"not_analyzed"
> > },
> > "code":{
> > "type":"string",
> > "index":"not_analyzed"
> > },
> > "description":{
> > "type":"string",
> > "index":"not_analyzed"
> > },
> > "dataPriority":{
> > "type":"long"
> > },
> > "specificationPriority":{
> > "type":"long"
> > },
> > "mediaPriority":{
> > "type":"long"
> > }
> > }
> > }}
> ```
> 
> and this is what's being returned when I look up the index metadata  
> through elasticsearch-head:
> 
> ```auto
> {
> > "state":"open",
> > "settings":{
> > "index.number_of_shards":5,
> > "index.number_of_replicas":1,
> > "index.version.created":200001
> > },
> > "mappings":{
> > "sp-type":{
> > "properties":{
> > "_rev":{
> > "index":"not_analyzed",
> > "type":"string"
> > },
> > "title":{
> > "index":"not_analyzed",
> > "type":"string"
> > },
> > "specificationPriority":{
> > "type":"long"
> > },
> > "dataPriority":{
> > "type":"long"
> > },
> > "description":{
> > "index":"not_analyzed",
> > "type":"string"
> > },
> > "code":{
> > "index":"not_analyzed",
> > "type":"string"
> > },
> > "mediaPriority":{
> > "type":"long"
> > }
> > }
> > }
> > },
> > "aliases":[]
> > }
> ```
> 
> Perhaps I am specifying in the wrong level of the mapping document?  
> Essentially, I would be happy if the \_id field would somehow make it into  
> the \_all field.
> 
> regards,  
> Andrius Juozapaitis

---

<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: [April 7, 2012, 3:22pm UTC](https://discuss.elastic.co/t/-id-field-missing-from-the-mapping/7254/3 "2012-04-07T15:22:34Z")

</div>

And, you don't need to store it, you will always get the \_id back from a  
search request, so no need to explicitly ask for it. There is no option to  
include the \_id in all.

On Sat, Apr 7, 2012 at 6:20 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> You are not placing the \_id mapping in the correct place, it should be on  
> the same level as the top most properties, and not within properties, see  
> more here:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/id-field.html).
> 
> On Fri, Apr 6, 2012 at 10:15 PM, Andrius Juozapaitis [andriusj@gmail.com](mailto:andriusj@gmail.com)wrote:
> 
> > Hey all,
> > 
> > I stumbled upon an issue with elasticsearch indexing couchdb documents:  
> > \_id field is indexed, but not added to the mapping, and hence the \_all  
> > field, so if I do a query\_string search, I have to specifically use the  
> > \_id:XXX123 to find the specific document. I am most likely missing  
> > something obvious. Here's the mapping I am submitting to elasticsearch:
> > 
> > ```auto
> > {"sp-type":{
> > >> "properties":{
> > >> "_id":{
> > >> "store":"yes",
> > >> "type":"string",
> > >> "index":"not_analyzed"
> > >> },
> > >> "_rev":{
> > >> "type":"string",
> > >> "index":"not_analyzed"
> > >> },
> > >> "title":{
> > >> "type":"string",
> > >> "index":"not_analyzed"
> > >> },
> > >> "code":{
> > >> "type":"string",
> > >> "index":"not_analyzed"
> > >> },
> > >> "description":{
> > >> "type":"string",
> > >> "index":"not_analyzed"
> > >> },
> > >> "dataPriority":{
> > >> "type":"long"
> > >> },
> > >> "specificationPriority":{
> > >> "type":"long"
> > >> },
> > >> "mediaPriority":{
> > >> "type":"long"
> > >> }
> > >> }
> > >> }}
> > ```
> > 
> > and this is what's being returned when I look up the index metadata  
> > through elasticsearch-head:
> > 
> > ```auto
> > {
> > >> "state":"open",
> > >> "settings":{
> > >> "index.number_of_shards":5,
> > >> "index.number_of_replicas":1,
> > >> "index.version.created":200001
> > >> },
> > >> "mappings":{
> > >> "sp-type":{
> > >> "properties":{
> > >> "_rev":{
> > >> "index":"not_analyzed",
> > >> "type":"string"
> > >> },
> > >> "title":{
> > >> "index":"not_analyzed",
> > >> "type":"string"
> > >> },
> > >> "specificationPriority":{
> > >> "type":"long"
> > >> },
> > >> "dataPriority":{
> > >> "type":"long"
> > >> },
> > >> "description":{
> > >> "index":"not_analyzed",
> > >> "type":"string"
> > >> },
> > >> "code":{
> > >> "index":"not_analyzed",
> > >> "type":"string"
> > >> },
> > >> "mediaPriority":{
> > >> "type":"long"
> > >> }
> > >> }
> > >> }
> > >> },
> > >> "aliases":[]
> > >> }
> > ```
> > 
> > Perhaps I am specifying in the wrong level of the mapping document?  
> > Essentially, I would be happy if the \_id field would somehow make it into  
> > the \_all field.
> > 
> > regards,  
> > Andrius Juozapaitis

---

<div class="post-metadata">

### Author: ![Andrius\_Juozapaitis](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@Andrius\_Juozapaitis](https://discuss.elastic.co/u/Andrius_Juozapaitis)
#### Post date: [April 7, 2012, 10:00pm UTC](https://discuss.elastic.co/t/-id-field-missing-from-the-mapping/7254/4 "2012-04-07T22:00:04Z")

</div>

I guess nothing prevents me from simply adding the \_id:querytext OR  
(\*:querytext) to compensate for that behavior.

Thanks,  
Andrius

On Saturday, April 7, 2012 6:22:34 PM UTC+3, kimchy wrote:

> And, you don't need to store it, you will always get the \_id back from a  
> search request, so no need to explicitly ask for it. There is no option to  
> include the \_id in all.
> 
> On Sat, Apr 7, 2012 at 6:20 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> 
> > You are not placing the \_id mapping in the correct place, it should be on  
> > the same level as the top most properties, and not within properties, see  
> > more here:  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/id-field.html).
> > 
> > On Fri, Apr 6, 2012 at 10:15 PM, Andrius Juozapaitis [andriusj@gmail.com](mailto:andriusj@gmail.com)wrote:
> > 
> > > Hey all,
> > > 
> > > I stumbled upon an issue with elasticsearch indexing couchdb documents:  
> > > \_id field is indexed, but not added to the mapping, and hence the \_all  
> > > field, so if I do a query\_string search, I have to specifically use the  
> > > \_id:XXX123 to find the specific document. I am most likely missing  
> > > something obvious. Here's the mapping I am submitting to elasticsearch:
> > > 
> > > ```auto
> > > {"sp-type":{
> > > >>> "properties":{
> > > >>> "_id":{
> > > >>> "store":"yes",
> > > >>> "type":"string",
> > > >>> "index":"not_analyzed"
> > > >>> },
> > > >>> "_rev":{
> > > >>> "type":"string",
> > > >>> "index":"not_analyzed"
> > > >>> },
> > > >>> "title":{
> > > >>> "type":"string",
> > > >>> "index":"not_analyzed"
> > > >>> },
> > > >>> "code":{
> > > >>> "type":"string",
> > > >>> "index":"not_analyzed"
> > > >>> },
> > > >>> "description":{
> > > >>> "type":"string",
> > > >>> "index":"not_analyzed"
> > > >>> },
> > > >>> "dataPriority":{
> > > >>> "type":"long"
> > > >>> },
> > > >>> "specificationPriority":{
> > > >>> "type":"long"
> > > >>> },
> > > >>> "mediaPriority":{
> > > >>> "type":"long"
> > > >>> }
> > > >>> }
> > > >>> }}
> > > ```
> > > 
> > > and this is what's being returned when I look up the index metadata  
> > > through elasticsearch-head:
> > > 
> > > ```auto
> > > {
> > > >>> "state":"open",
> > > >>> "settings":{
> > > >>> "index.number_of_shards":5,
> > > >>> "index.number_of_replicas":1,
> > > >>> "index.version.created":200001
> > > >>> },
> > > >>> "mappings":{
> > > >>> "sp-type":{
> > > >>> "properties":{
> > > >>> "_rev":{
> > > >>> "index":"not_analyzed",
> > > >>> "type":"string"
> > > >>> },
> > > >>> "title":{
> > > >>> "index":"not_analyzed",
> > > >>> "type":"string"
> > > >>> },
> > > >>> "specificationPriority":{
> > > >>> "type":"long"
> > > >>> },
> > > >>> "dataPriority":{
> > > >>> "type":"long"
> > > >>> },
> > > >>> "description":{
> > > >>> "index":"not_analyzed",
> > > >>> "type":"string"
> > > >>> },
> > > >>> "code":{
> > > >>> "index":"not_analyzed",
> > > >>> "type":"string"
> > > >>> },
> > > >>> "mediaPriority":{
> > > >>> "type":"long"
> > > >>> }
> > > >>> }
> > > >>> }
> > > >>> },
> > > >>> "aliases":[]
> > > >>> }
> > > ```
> > > 
> > > Perhaps I am specifying in the wrong level of the mapping document?  
> > > Essentially, I would be happy if the \_id field would somehow make it into  
> > > the \_all field.
> > > 
> > > regards,  
> > > Andrius Juozapaitis

---

<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:33am UTC](https://discuss.elastic.co/t/-id-field-missing-from-the-mapping/7254/5 "2017-07-06T03:33:18Z")

</div>


