# Creating an index with existing index

**URL:** <https://discuss.elastic.co/t/creating-an-index-with-existing-index/323550>\
**Category:** Elasticsearch\
**Created:** [January 19, 2023, 9:55pm UTC](https://discuss.elastic.co/t/creating-an-index-with-existing-index/323550 "2023-01-19T21:55:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elrozario](https://avatars.discourse-cdn.com/v4/letter/e/8e8cbc/32.png) [@elrozario](https://discuss.elastic.co/u/elrozario)\
**Post date:** [January 19, 2023, 9:55pm UTC](https://discuss.elastic.co/t/creating-an-index-with-existing-index/323550/1 "2023-01-19T21:55:56Z")

</div>

Hello,

I have many indexes named

.ds-traces-apm-default-2022.12.12-000124  
.ds-traces-apm-default-2022.12.17-000125  
.ds-traces-apm-default-2022.12.20-000126  
.ds-traces-apm-default-2022.12.22-000127  
.ds-traces-apm-default-2023.01.04-000139

and they have a,b,c,d,e,f,g,h etc columns.  
I am trying to create a new index that would have a, b, c columns/fields from the first index only if they satisfy condition. Is it possible to do that?

````plaintext
{
 "source": {
   "index": ".ds-traces-apm-default-*",
 "query": {
   "match_phrase": {
     "url.path": "/TicketCheckerServices/v2/ticketInquiry"
   }
 }
 },
 "dest": { 
   "index": "test1"
   }
}```

With this I am getting an error 

```{
 "error": {
   "root_cause": [
     {
       "type": "parse_exception",
       "reason": "request body is required"
     }
   ],
   "type": "parse_exception",
   "reason": "request body is required"
 },
 "status": 400
}```
````

---

<div class="post-metadata">

**Author:** ![elrozario](https://avatars.discourse-cdn.com/v4/letter/e/8e8cbc/32.png) [@elrozario](https://discuss.elastic.co/u/elrozario)\
**Post date:** [January 27, 2023, 8:15pm UTC](https://discuss.elastic.co/t/creating-an-index-with-existing-index/323550/2 "2023-01-27T20:15:28Z")

</div>

Actually I figured it out myself.  
You can do it by specifying the \_source filter. for example

````auto
 "source": {
   "index": ".ds-traces-apm-default-*",
   "_source" : ["sourceindexfieldname1", "sourceindexfieldname2", ...],
 "query": {
   "match_phrase": {
     "url.path": "/TicketCheckerServices/v2/ticketInquiry"
   }
 }
 },
 "dest": { 
   "index": "test1"
   }
}```
````

---

<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:** [February 24, 2023, 8:16pm UTC](https://discuss.elastic.co/t/creating-an-index-with-existing-index/323550/3 "2023-02-24T20:16:14Z")

</div>

Closed on February 24, 2023, 8:16pm UTC

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