# Cannot delete field at reindexing

**URL:** <https://discuss.elastic.co/t/cannot-delete-field-at-reindexing/235607>\
**Category:** Elasticsearch\
**Created:** [June 3, 2020, 5:03pm UTC](https://discuss.elastic.co/t/cannot-delete-field-at-reindexing/235607 "2020-06-03T17:03:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Attila816](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/attila816/32/68007_2.png) [@Attila816](https://discuss.elastic.co/u/Attila816)\
**Post date:** [June 3, 2020, 5:03pm UTC](https://discuss.elastic.co/t/cannot-delete-field-at-reindexing/235607/1 "2020-06-03T17:03:27Z")

</div>

Hi,

I would like to delete a field from a mapping.  
As I've read I can do this with reindexing the whole documents but currently however I create the new index without the removed field the reindexed documents contains that field.  
How can I reindex the documents without containing the old field?

I use the following script at reindexing:

> ctx.\_source.remove('text')

New Mapping looks like this:

> {  
> "mapping": {  
> "properties": {  
> "id": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "num1": {  
> "type": "long"  
> },  
> "parentfolderid": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> },  
> "relation": {  
> "type": "join",  
> "eager\_global\_ordinals": true,  
> "relations": {  
> "root": "field"  
> }  
> },  
> "string1": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "keyword",  
> "ignore\_above": 256  
> }  
> }  
> }  
> }  
> }  
> }

I receive a response like this when I query the new documents:

> {  
> "took" : 0,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 1,  
> "successful" : 1,  
> "skipped" : 0,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : {  
> "value" : 4,  
> "relation" : "eq"  
> },  
> "max\_score" : 1.0,  
> "hits" : [  
> {  
> "\_index" : "basic\_tests\_d50d27468a024757ad8044c082270eed",  
> "\_type" : "\_doc",  
> "\_id" : "0",  
> "\_score" : 1.0,  
> "\_source" : {  
> "id" : "0",  
> "relation" : "root",  
> "parentfolderid" : "549272721"  
> }  
> },  
> {  
> "\_index" : "basic\_tests\_d50d27468a024757ad8044c082270eed",  
> "\_type" : "\_doc",  
> "\_id" : "0\_text",  
> "\_score" : 1.0,  
> "\_routing" : "0",  
> "\_source" : {  
> "id" : "0\_text",  
> "relation" : {  
> "parent" : "0",  
> "name" : "field"  
> }  
> }  
> },  
> {  
> "\_index" : "basic\_tests\_d50d27468a024757ad8044c082270eed",  
> "\_type" : "\_doc",  
> "\_id" : "0\_string1",  
> "\_score" : 1.0,  
> "\_routing" : "0",  
> "\_source" : {  
> "string1" : "alma\_is\_alma 123\_456 1353917046 one two three four five six seven eight nine ten",  
> "id" : "0\_string1",  
> "relation" : {  
> "parent" : "0",  
> "name" : "field"  
> }  
> }  
> },  
> {  
> "\_index" : "basic\_tests\_d50d27468a024757ad8044c082270eed",  
> "\_type" : "\_doc",  
> "\_id" : "0\_num1",  
> "\_score" : 1.0,  
> "\_routing" : "0",  
> "\_source" : {  
> "num1" : 1825286935,  
> "id" : "0\_num1",  
> "relation" : {  
> "parent" : "0",  
> "name" : "field"  
> }  
> }  
> }  
> ]  
> }  
> }

Thanks

---

<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 1, 2020, 5:03pm UTC](https://discuss.elastic.co/t/cannot-delete-field-at-reindexing/235607/2 "2020-07-01T17:03:27Z")

</div>

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