# How to replacement - with 0 by gsub processor in ingest pipeline?

**URL:** <https://discuss.elastic.co/t/how-to-replacement-with-0-by-gsub-processor-in-ingest-pipeline/127251>\
**Category:** Elasticsearch\
**Created:** [April 9, 2018, 6:18am UTC](https://discuss.elastic.co/t/how-to-replacement-with-0-by-gsub-processor-in-ingest-pipeline/127251 "2018-04-09T06:18:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackyshen](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@jackyshen](https://discuss.elastic.co/u/jackyshen)\
**Post date:** [April 9, 2018, 6:18am UTC](https://discuss.elastic.co/t/how-to-replacement-with-0-by-gsub-processor-in-ingest-pipeline/127251/1 "2018-04-09T06:18:05Z")

</div>

Some of the value for field price is "-",so I want to replace it with 0 by gsub processor ,then I write the following code, however it doesn't work, how to write code?

{  
"gsub": {  
"field": "price",  
"pattern": "-",  
"replacement": 0  
}

BTW, the ES version is 5.5, and I mapped the type of price to double.

The following error message got from the filebeat log file"{"type":"mapper\_parsing\_exception","reason":"failed to parse [price]","caused\_by":{"type":"number\_format\_exception","reason":"For input string: "-""}}"

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 9, 2018, 8:15am UTC](https://discuss.elastic.co/t/how-to-replacement-with-0-by-gsub-processor-in-ingest-pipeline/127251/2 "2018-04-09T08:15:11Z")

</div>

hey,

have you tried `replacement: "0.0"` plus a `convert` processor to change your fieldname?

Also please change your full pipeline, or at least provide a full reproducible example using the simulate pipeline API, this makes it a hundred times easier for others to check out your example.

--Alex

---

<div class="post-metadata">

**Author:** ![jackyshen](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@jackyshen](https://discuss.elastic.co/u/jackyshen)\
**Post date:** [April 9, 2018, 8:28am UTC](https://discuss.elastic.co/t/how-to-replacement-with-0-by-gsub-processor-in-ingest-pipeline/127251/3 "2018-04-09T08:28:35Z")

</div>

The full pipeline is

-- pipeline  
PUT \_ingest/pipeline/log-nginx-accesslog  
{  
"description": "Pipeline for parsing the Nginx access logs",  
"processors": [{  
"grok": {  
"field": "message",  
"patterns": [  
"%{GREEDYDATA:x\_forword} %{DATA:price} "%{URIPATHPARAM:uri}""  
],  
"ignore\_missing": true  
}  
},{  
"gsub": {  
"field": "price",  
"pattern": "-",  
"replacement": 0  
}  
}, {  
"remove": {  
"field": "nginx.error.time"  
}  
}],  
"on\_failure" : [{  
"set" : {  
"field" : "error",  
"value" : "{{ \_ingest.on\_failure\_message }}"  
}  
}]  
}

--template

PUT \_template/template\_log-platform  
{  
"template": "nginxlog\*",  
"settings": {  
"number\_of\_shards": 6,  
"number\_of\_replicas": 1  
},  
"mappings": {  
"doc": {  
"\_source": {  
"enabled": true  
},  
"properties": {  
"bytes": {  
"type": "integer"  
},

```
     "price": {
      "type": "double"
    }
    ,
     "request_time": {
      "type": "double"
    }
    
  }
}

```

}  
}

---

<div class="post-metadata">

**Author:** ![jackyshen](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@jackyshen](https://discuss.elastic.co/u/jackyshen)\
**Post date:** [April 9, 2018, 2:28pm UTC](https://discuss.elastic.co/t/how-to-replacement-with-0-by-gsub-processor-in-ingest-pipeline/127251/4 "2018-04-09T14:28:07Z")

</div>

I tried your method, however it still doesn't work.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 9, 2018, 2:36pm UTC](https://discuss.elastic.co/t/how-to-replacement-with-0-by-gsub-processor-in-ingest-pipeline/127251/5 "2018-04-09T14:36:50Z")

</div>

A full reproducible example would be great. Maybe you can use the [Ingest Simulate API](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/simulate-pipeline-api.html), which can contain the pipeline **and** sample documents in a single API call. That would help a lot!

--Alex

---

<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:** [May 7, 2018, 2:36pm UTC](https://discuss.elastic.co/t/how-to-replacement-with-0-by-gsub-processor-in-ingest-pipeline/127251/6 "2018-05-07T14:36:57Z")

</div>

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