# How to get particular element by index

**URL:** <https://discuss.elastic.co/t/how-to-get-particular-element-by-index/94277>\
**Category:** Elasticsearch\
**Created:** [July 24, 2017, 6:45am UTC](https://discuss.elastic.co/t/how-to-get-particular-element-by-index/94277 "2017-07-24T06:45:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shehry94](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@shehry94](https://discuss.elastic.co/u/shehry94)\
**Post date:** [July 24, 2017, 6:45am UTC](https://discuss.elastic.co/t/how-to-get-particular-element-by-index/94277/1 "2017-07-24T06:45:28Z")

</div>

Say I have this document stored.

###exemplary data  
{"name": "haris","projects": [{"title": "Splunk"},{"title": "QRadar"},{"title": "LogAnalysis"}]}

```
{"name": "khalid","projects": [{"title": "MS"},{"title": "Google"},{"title": "Apple"}]}

{"name": "Hamid","projects": [{"title": "Toyota"},{"title": "Honda"},{"title": "Kia"}]}

```

###code for mapping  
PUT index\_name  
{  
"mappings": {  
"iterations\_type": {  
"properties": {  
"projects": {  
"type": "nested",  
"include\_in\_parent": true  
}  
}  
}  
}  
}

**My QUESTION** : I want to get 2nd element of "projects" array against some specific name e.g "name": "khalid".

**What I tried so far:**  
I am new to ES and I searched forums for the answer, some suggest to specify mapping of "projects" key. I tried that too and the issue I face is

1. when I create empty index, specify the mapping first and then insert the data, I get an error like "reason": "object mapping ["projects"] can't be changed from nested to non-nested"
2. when I create empty index, insert data first and then specify the mapping, I get and error like ""reason": "index [\<\>] already exists"  
ard for me to specify mapping for each field explicitly

Thanks in advance

---

<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 21, 2017, 6:45am UTC](https://discuss.elastic.co/t/how-to-get-particular-element-by-index/94277/2 "2017-08-21T06:45:32Z")

</div>

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