Skip to content

Commit 1c20d2e

Browse files
committed
Revert "Ingest node - user agent, move device to an object (elastic#38115)"
This reverts commit 5b008a3. Related: elastic/beats#10650 Will replace this commit with the 6.7 version
1 parent 8cd1796 commit 1c20d2e

File tree

5 files changed

+10
-21
lines changed

5 files changed

+10
-21
lines changed

docs/reference/ingest/processors/user-agent.asciidoc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ Which returns
6767
"version": "10.10.5",
6868
"full": "Mac OS X 10.10.5"
6969
},
70-
"device" : {
71-
"name" : "Other"
72-
},
70+
"device": "Other"
7371
}
7472
}
7573
}

modules/ingest-user-agent/src/main/java/org/elasticsearch/ingest/useragent/UserAgentProcessor.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,11 @@ public IngestDocument execute(IngestDocument ingestDocument) {
134134
}
135135
break;
136136
case DEVICE:
137-
Map<String, String> deviceDetails = new HashMap<>(1);
138137
if (uaClient.device != null && uaClient.device.name != null) {
139-
deviceDetails.put("name", uaClient.device.name);
138+
uaDetails.put("device", uaClient.device.name);
140139
} else {
141-
deviceDetails.put("name", "Other");
140+
uaDetails.put("device", "Other");
142141
}
143-
uaDetails.put("device", deviceDetails);
144142
break;
145143
}
146144
}

modules/ingest-user-agent/src/test/java/org/elasticsearch/ingest/useragent/UserAgentProcessorTests.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ public void testCommonBrowser() throws Exception {
110110
os.put("version", "10.9.2");
111111
os.put("full", "Mac OS X 10.9.2");
112112
assertThat(target.get("os"), is(os));
113-
Map<String, String> device = new HashMap<>();
114-
device.put("name", "Other");
115-
assertThat(target.get("device"), is(device));
113+
assertThat(target.get("device"), is("Other"));
116114
}
117115

118116
@SuppressWarnings("unchecked")
@@ -138,9 +136,7 @@ public void testUncommonDevice() throws Exception {
138136
os.put("full", "Android 3.0");
139137
assertThat(target.get("os"), is(os));
140138

141-
Map<String, String> device = new HashMap<>();
142-
device.put("name", "Motorola Xoom");
143-
assertThat(target.get("device"), is(device));
139+
assertThat(target.get("device"), is("Motorola Xoom"));
144140
}
145141

146142
@SuppressWarnings("unchecked")
@@ -161,9 +157,7 @@ public void testSpider() throws Exception {
161157
assertNull(target.get("version"));
162158
assertNull(target.get("os"));
163159

164-
Map<String, String> device = new HashMap<>();
165-
device.put("name", "Spider");
166-
assertThat(target.get("device"), is(device));
160+
assertThat(target.get("device"), is("Spider"));
167161
}
168162

169163
@SuppressWarnings("unchecked")
@@ -186,8 +180,7 @@ public void testUnknown() throws Exception {
186180
assertNull(target.get("build"));
187181

188182
assertNull(target.get("os"));
189-
Map<String, String> device = new HashMap<>();
190-
device.put("name", "Other");
191-
assertThat(target.get("device"), is(device));
183+
184+
assertThat(target.get("device"), is("Other"));
192185
}
193186
}

modules/ingest-user-agent/src/test/resources/rest-api-spec/test/ingest-useragent/20_useragent_processor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
- match: { _source.user_agent.original: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.149 Safari/537.36" }
3333
- match: { _source.user_agent.os: {"name":"Mac OS X", "version":"10.9.2", "full":"Mac OS X 10.9.2"} }
3434
- match: { _source.user_agent.version: "33.0.1750" }
35-
- match: { _source.user_agent.device: {"name": "Other" }}
35+
- match: { _source.user_agent.device: "Other" }
3636

3737
---
3838
"Test user agent processor with parameters":

modules/ingest-user-agent/src/test/resources/rest-api-spec/test/ingest-useragent/30_custom_regex.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@
3030
id: 1
3131
- match: { _source.field1: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.149 Safari/537.36" }
3232
- match: { _source.user_agent.name: "Test" }
33-
- match: { _source.user_agent.device: {"name": "Other" }}
33+
- match: { _source.user_agent.device: "Other" }
3434
- is_false: _source.user_agent.os
3535
- is_false: _source.user_agent.version

0 commit comments

Comments
 (0)