I want to replace multiple (more than 3) newlines (\n\n\n) with two newlines (\n\n). If I set "\n\n" as a replacement string the the gsub object it replaces \n\n\n\ with nn.
Here you can find my _simulate ingest pipeline.
POST _ingest/pipeline/_simulate
{
"pipeline": {
"processors": [
{
"gsub": {
"field": "message",
"pattern": """Page \d of \d""",
"replacement": "",
"ignore_missing": false,
"description": "Remove Page x of x",
"on_failure": [
{
"append": {
"description": "Record error information",
"field": "_ingestion_errors",
"value": "Processor 'gsub' with tag 'remove_page_numbers' in pipeline '{{ _ingest.on_failure_pipeline }}' failed with message '{{ _ingest.on_failure_message }}'"
}
}
]
}
},
{
"gsub": {
"field": "message",
"pattern": "\\n\\n",
"replacement": "\\n",
"ignore_missing": false,
"description": "Replace multiple newlines at the beginning",
"on_failure": [
{
"append": {
"description": "Record error information",
"field": "_ingestion_errors",
"value": "Processor 'gsub' with tag 'remove_page_numbers' in pipeline '{{ _ingest.on_failure_pipeline }}' failed with message '{{ _ingest.on_failure_message }}'"
}
}
]
}
}
]
},
"docs": [
{
"_source": {
"message": """
Marketing Intern
May 2009 - August 2009 (4 months)
New York City Metropolitan Area
Jump PR
Public Relations Intern
Page 2 of 3
May 2008 - August 2008 (4 months)
New York City Metropolitan Area
Education
University
Bachelor of Arts - BA, Communication and Media Studies · (August 2010 - May
2014)
Senior High School
· (September 2006 - June 2010)
Page 3 of 3"""
}
}
]
}
How does the replacement string have to look like that it that it set \n\n?
Thanks for you help.