Skip to content

Commit 3de7971

Browse files
committed
Rename ignore_empty_value to remove_empty_values
1 parent 21006dd commit 3de7971

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

docs/reference/enrich-processor/xml-processor.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $$$xml-options$$$
1818
| `ignore_missing` | no | `false` | If `true` and `field` does not exist, the processor quietly exits without modifying the document. |
1919
| `ignore_failure` | no | `false` | Ignore failures for the processor. When `true` and XML parsing fails, adds `_xmlparsefailure` tag to the document. See [Handling pipeline failures](docs-content://manage-data/ingest/transform-enrich/ingest-pipelines.md#handling-pipeline-failures). |
2020
| `to_lower` | no | `false` | Convert XML element names and attribute names to lowercase. |
21-
| `ignore_empty_value` | no | `false` | If `true`, the processor will filter out null and empty values from the parsed XML structure, including empty elements, elements with null values, and elements with whitespace-only content. |
21+
| `remove_empty_values` | no | `false` | If `true`, the processor will filter out null and empty values from the parsed XML structure, including empty elements, elements with null values, and elements with whitespace-only content. |
2222
| `remove_namespaces` | no | `false` | If `true`, removes namespace prefixes from element and attribute names. |
2323
| `force_content` | no | `false` | If `true`, forces text content and attributes to always parse to a hash value with `#text` key for content. |
2424
| `force_array` | no | `false` | If `true`, forces all parsed values to be arrays. Single elements are wrapped in arrays. |
@@ -37,7 +37,7 @@ $$$xml-options$$$
3737
"xml": {
3838
"field": "xml_field",
3939
"target_field": "parsed_xml",
40-
"ignore_empty_value": true
40+
"remove_empty_values": true
4141
}
4242
}
4343
```
@@ -94,7 +94,7 @@ Result:
9494

9595
### Filtering empty values
9696

97-
When `ignore_empty_value` is set to `true`, the processor will remove empty elements from the parsed XML:
97+
When `remove_empty_values` is set to `true`, the processor will remove empty elements from the parsed XML:
9898

9999
```console
100100
POST _ingest/pipeline/_simulate
@@ -105,7 +105,7 @@ POST _ingest/pipeline/_simulate
105105
"xml": {
106106
"field": "xml_content",
107107
"target_field": "parsed_xml",
108-
"ignore_empty_value": true
108+
"remove_empty_values": true
109109
}
110110
}
111111
]
@@ -624,7 +624,7 @@ The XML processor supports:
624624

625625
- **Elements with text content**: Converted to key-value pairs where the element name is the key and text content is the value
626626
- **Nested elements**: Converted to nested JSON objects
627-
- **Empty elements**: Converted to `null` values (can be filtered with `ignore_empty_value`)
627+
- **Empty elements**: Converted to `null` values (can be filtered with `remove_empty_values`)
628628
- **Repeated elements**: Converted to arrays when multiple elements with the same name exist at the same level
629629
- **XML attributes**: Included as properties in the JSON object alongside element content. When an element has both attributes and text content, the text is stored under a special `#text` key
630630
- **Mixed content**: Elements with both text and child elements include text under a special `#text` key while attributes and child elements become object properties

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/XmlProcessor.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
* - XPath extraction with namespace support
4545
* - Configurable options: force_array, force_content, remove_namespaces, to_lower
4646
* - Strict parsing mode for XML validation
47-
* - Empty value filtering with ignore_empty_value option
47+
* - Empty value filtering with remove_empty_values option
4848
* - Logstash-compatible error handling and behavior
4949
*/
5050
public final class XmlProcessor extends AbstractProcessor {
@@ -71,7 +71,7 @@ public final class XmlProcessor extends AbstractProcessor {
7171
private final boolean ignoreMissing;
7272
private final boolean ignoreFailure;
7373
private final boolean toLower;
74-
private final boolean ignoreEmptyValue;
74+
private final boolean removeEmptyValues;
7575
private final boolean storeXml;
7676
private final boolean removeNamespaces;
7777
private final boolean forceContent;
@@ -89,7 +89,7 @@ public final class XmlProcessor extends AbstractProcessor {
8989
boolean ignoreMissing,
9090
boolean ignoreFailure,
9191
boolean toLower,
92-
boolean ignoreEmptyValue,
92+
boolean removeEmptyValues,
9393
boolean storeXml,
9494
boolean removeNamespaces,
9595
boolean forceContent,
@@ -104,7 +104,7 @@ public final class XmlProcessor extends AbstractProcessor {
104104
this.ignoreMissing = ignoreMissing;
105105
this.ignoreFailure = ignoreFailure;
106106
this.toLower = toLower;
107-
this.ignoreEmptyValue = ignoreEmptyValue;
107+
this.removeEmptyValues = removeEmptyValues;
108108
this.storeXml = storeXml;
109109
this.removeNamespaces = removeNamespaces;
110110
this.forceContent = forceContent;
@@ -127,8 +127,8 @@ public boolean isIgnoreMissing() {
127127
return ignoreMissing;
128128
}
129129

130-
public boolean isIgnoreEmptyValue() {
131-
return ignoreEmptyValue;
130+
public boolean isRemoveEmptyValues() {
131+
return removeEmptyValues;
132132
}
133133

134134
public boolean isStoreXml() {
@@ -206,7 +206,7 @@ public String getType() {
206206

207207
/**
208208
* Determines if a value should be considered empty for filtering purposes.
209-
* Used by the ignore_empty_value feature to filter out empty content.
209+
* Used by the remove_empty_values feature to filter out empty content.
210210
*
211211
* Considers empty:
212212
* - null values
@@ -432,7 +432,7 @@ public XmlProcessor create(
432432
boolean ignoreMissing = ConfigurationUtils.readBooleanProperty(TYPE, processorTag, config, "ignore_missing", false);
433433
boolean ignoreFailure = ConfigurationUtils.readBooleanProperty(TYPE, processorTag, config, "ignore_failure", false);
434434
boolean toLower = ConfigurationUtils.readBooleanProperty(TYPE, processorTag, config, "to_lower", false);
435-
boolean ignoreEmptyValue = ConfigurationUtils.readBooleanProperty(TYPE, processorTag, config, "ignore_empty_value", false);
435+
boolean removeEmptyValues = ConfigurationUtils.readBooleanProperty(TYPE, processorTag, config, "remove_empty_values", false);
436436
boolean storeXml = ConfigurationUtils.readBooleanProperty(TYPE, processorTag, config, "store_xml", true);
437437
boolean removeNamespaces = ConfigurationUtils.readBooleanProperty(TYPE, processorTag, config, "remove_namespaces", false);
438438
boolean forceContent = ConfigurationUtils.readBooleanProperty(TYPE, processorTag, config, "force_content", false);
@@ -502,7 +502,7 @@ public XmlProcessor create(
502502
ignoreMissing,
503503
ignoreFailure,
504504
toLower,
505-
ignoreEmptyValue,
505+
removeEmptyValues,
506506
storeXml,
507507
removeNamespaces,
508508
forceContent,
@@ -628,8 +628,8 @@ public void startElement(String uri, String localName, String qName, org.xml.sax
628628
String attrName = getAttributeName(attributes.getURI(i), attributes.getLocalName(i), attributes.getQName(i));
629629
String attrValue = attributes.getValue(i);
630630

631-
// Apply ignoreEmptyValue filtering to attributes
632-
if (ignoreEmptyValue == false || isEmptyValue(attrValue) == false) {
631+
// Apply removeEmptyValues filtering to attributes
632+
if (removeEmptyValues == false || isEmptyValue(attrValue) == false) {
633633
element.put(attrName, attrValue);
634634
}
635635
}
@@ -683,7 +683,7 @@ public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXE
683683
// Add to DOM text node if needed
684684
if (buildDom && !domElementStack.isEmpty()) {
685685
String text = new String(ch, start, length);
686-
if (!text.trim().isEmpty() || !ignoreEmptyValue) {
686+
if (!text.trim().isEmpty() || !removeEmptyValues) {
687687
org.w3c.dom.Text textNode = domDocument.createTextNode(text);
688688
domElementStack.peek().appendChild(textNode);
689689
}
@@ -705,7 +705,7 @@ public void endElement(String uri, String localName, String qName) throws org.xm
705705
// Add repeated elements as arrays
706706
for (Map.Entry<String, List<Object>> entry : repeatedElements.entrySet()) {
707707
List<Object> values = entry.getValue();
708-
if (ignoreEmptyValue == false || values.isEmpty() == false) {
708+
if (removeEmptyValues == false || values.isEmpty() == false) {
709709
element.put(entry.getKey(), values);
710710
}
711711
}
@@ -718,7 +718,7 @@ public void endElement(String uri, String localName, String qName) throws org.xm
718718
Object elementValue;
719719
if (hasText == false && hasChildren == false) {
720720
// Empty element
721-
if (ignoreEmptyValue == false) {
721+
if (removeEmptyValues == false) {
722722
elementValue = applyForceArray(elementName, null);
723723
} else {
724724
elementValue = null;
@@ -727,12 +727,12 @@ public void endElement(String uri, String localName, String qName) throws org.xm
727727
// Only text content
728728
if (forceContent) {
729729
Map<String, Object> contentMap = new HashMap<>();
730-
if (ignoreEmptyValue == false || isEmptyValue(trimmedText) == false) {
730+
if (removeEmptyValues == false || isEmptyValue(trimmedText) == false) {
731731
contentMap.put("#text", trimmedText);
732732
}
733733
elementValue = contentMap;
734734
} else {
735-
if (ignoreEmptyValue && isEmptyValue(trimmedText)) {
735+
if (removeEmptyValues && isEmptyValue(trimmedText)) {
736736
elementValue = null;
737737
} else {
738738
elementValue = trimmedText;
@@ -744,7 +744,7 @@ public void endElement(String uri, String localName, String qName) throws org.xm
744744
elementValue = (forceArray && forceContent) ? applyForceArray(elementName, element) : element;
745745
} else {
746746
// Both text and children/attributes
747-
if (ignoreEmptyValue == false || isEmptyValue(trimmedText) == false) {
747+
if (removeEmptyValues == false || isEmptyValue(trimmedText) == false) {
748748
element.put("#text", trimmedText);
749749
}
750750
elementValue = (forceArray && forceContent) ? applyForceArray(elementName, element) : element;

modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/XmlProcessorFactoryTests.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ private Map<String, Object> createConfigWithOptions(String fieldName, String...
140140
case "to_lower":
141141
config.put("to_lower", true);
142142
break;
143-
case "ignore_empty_value":
144-
config.put("ignore_empty_value", true);
143+
case "remove_empty_values":
144+
config.put("remove_empty_values", true);
145145
break;
146146
case "store_xml":
147147
config.put("store_xml", false); // Test false case since default is true
@@ -186,14 +186,14 @@ public void testCreate() throws Exception {
186186
config.put("ignore_missing", true);
187187
config.put("ignore_failure", true);
188188
config.put("to_lower", true);
189-
config.put("ignore_empty_value", true);
189+
config.put("remove_empty_values", true);
190190

191191
XmlProcessor processor = createProcessor(config);
192192

193193
assertThat(processor.getField(), equalTo(DEFAULT_FIELD));
194194
assertThat(processor.getTargetField(), equalTo(DEFAULT_TARGET_FIELD));
195195
assertThat(processor.isIgnoreMissing(), equalTo(true));
196-
assertThat(processor.isIgnoreEmptyValue(), equalTo(true));
196+
assertThat(processor.isRemoveEmptyValues(), equalTo(true));
197197
}
198198

199199
public void testCreateWithDefaults() throws Exception {
@@ -203,22 +203,22 @@ public void testCreateWithDefaults() throws Exception {
203203
assertThat(processor.getField(), equalTo(DEFAULT_FIELD));
204204
assertThat(processor.getTargetField(), equalTo(DEFAULT_FIELD));
205205
assertThat(processor.isIgnoreMissing(), equalTo(false));
206-
assertThat(processor.isIgnoreEmptyValue(), equalTo(false));
206+
assertThat(processor.isRemoveEmptyValues(), equalTo(false));
207207
}
208208

209209
public void testCreateMissingField() throws Exception {
210210
Map<String, Object> config = new HashMap<>(); // Empty config - no field specified
211211
expectCreationFailure(config, ElasticsearchParseException.class, "[field] required property is missing");
212212
}
213213

214-
public void testCreateWithIgnoreEmptyValueOnly() throws Exception {
214+
public void testCreateWithRemoveEmptyValuesOnly() throws Exception {
215215
Map<String, Object> config = createBaseConfig();
216-
config.put("ignore_empty_value", true);
216+
config.put("remove_empty_values", true);
217217

218218
XmlProcessor processor = createProcessor(config);
219219

220220
assertThat(processor.getField(), equalTo(DEFAULT_FIELD));
221-
assertThat(processor.isIgnoreEmptyValue(), equalTo(true));
221+
assertThat(processor.isRemoveEmptyValues(), equalTo(true));
222222
assertThat(processor.isIgnoreMissing(), equalTo(false)); // other flags should remain default
223223
}
224224

modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/XmlProcessorTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,9 @@ public void testIgnoreMissing() {
475475
}
476476

477477
/**
478-
* Test that ignore_empty_value correctly filters out empty values from arrays and mixed content.
478+
* Test that remove_empty_values correctly filters out empty values from arrays and mixed content.
479479
*/
480-
public void testIgnoreEmptyValue() {
480+
public void testRemoveEmptyValues() {
481481
// XML with mixed empty and non-empty elements, including array elements with mixed empty/non-empty values
482482
String xml = "<root>"
483483
+ " <empty></empty>"
@@ -495,7 +495,7 @@ public void testIgnoreEmptyValue() {
495495
+ "</root>";
496496

497497
Map<String, Object> config = new HashMap<>();
498-
config.put("ignore_empty_value", true);
498+
config.put("remove_empty_values", true);
499499
XmlProcessor processor = createTestProcessor(config);
500500

501501
IngestDocument ingestDocument = createTestIngestDocument(xml);

0 commit comments

Comments
 (0)