Don't allow colliding flat meta values
Change-Id: Id280934f813a67eff3dd2a1ba84a1b876906910d
diff --git a/src/main/java/de/ids_mannheim/korap/response/Match.java b/src/main/java/de/ids_mannheim/korap/response/Match.java
index c5ab6ab..9a70922 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Match.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Match.java
@@ -2494,11 +2494,11 @@
// Legacy flat field support
String mfs = mf.key;
String value = this.getFieldValue(mfs);
- if (value != null)
+ if (value != null && !json.has(mfs))
json.set(mfs, new TextNode(value));
};
- this.addMessage(0, "Support for flat field values is eprecated");
+ this.addMessage(0, "Support for flat field values is deprecated");
return json;
};
diff --git a/src/main/java/de/ids_mannheim/korap/response/Text.java b/src/main/java/de/ids_mannheim/korap/response/Text.java
index 68dab3c..dc77603 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Text.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Text.java
@@ -55,11 +55,11 @@
// Legacy flat field support
String mfs = mf.key;
String value = this.getFieldValue(mfs);
- if (value != null)
+ if (value != null && !json.has(mfs))
json.set(mfs, new TextNode(value));
};
- this.addMessage(0, "Support for flat field values is eprecated");
+ this.addMessage(0, "Support for flat field values is deprecated");
// Match was no match
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java b/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java
index bbf1b3e..44db7e1 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java
@@ -151,7 +151,6 @@
assertEquals("match-GOE_AGX.00002-p7-8",
res.at("/matches/0/matchID").asText());
-
// All fields
jsonString = getJsonString(getClass()
.getResource("/queries/metas/fields_all.jsonld").getFile());
@@ -213,7 +212,7 @@
assertEquals("Goethe: Maximen und Reflexionen, (1827-1842)",
res.at("/matches/0/docTitle").asText());
assertEquals("1827", res.at("/matches/0/creationDate").asText());
- // assertEquals("372-377", res.at("/matches/0/pages").asText());
+ assertTrue(res.at("/matches/0/pages").isMissingNode());
assertEquals("match-GOE_AGX.00002-p7-8",
res.at("/matches/0/matchID").asText());