Remove hardwired metadata deserialization with support for legacy metadata fields
Change-Id: Icfb159a89b7b8a390812c32ec744290a20029ea0
diff --git a/Changes b/Changes
index b325da6..e465ea2 100644
--- a/Changes
+++ b/Changes
@@ -1,10 +1,12 @@
-0.58.4 2019-01-09
+0.58.4 2019-01-10
- [cleanup] Remove deprecated methods setLicense/getLicense,
setTokenization/getTokenization, setLayerInfo/getLayerInfo,
setField/getField (including json serialization)
(diewald)
- [cleanup] Remove redundancy for meta field setting in
- AbstractDocument and FieldDocument.
+ AbstractDocument and FieldDocument (diewald)
+ - [cleanup] Remove hardwired deserialization of legacy metadata
+ fields (diewald)
0.58.3 2018-12-17
- [feature] Introduced attachements as meta data fields
diff --git a/src/main/java/de/ids_mannheim/korap/index/AbstractDocument.java b/src/main/java/de/ids_mannheim/korap/index/AbstractDocument.java
index bf43557..e0dc582 100644
--- a/src/main/java/de/ids_mannheim/korap/index/AbstractDocument.java
+++ b/src/main/java/de/ids_mannheim/korap/index/AbstractDocument.java
@@ -36,17 +36,73 @@
* @author diewald
*/
@JsonInclude(Include.NON_EMPTY)
-@JsonIgnoreProperties(ignoreUnknown = true)
+// @JsonIgnoreProperties(ignoreUnknown = true)
public abstract class AbstractDocument extends Response {
ObjectMapper mapper = new ObjectMapper();
private String primaryData;
+ private static HashSet<String> legacyStringFields =
+ new HashSet<String>(Arrays.asList(
+ "pubPlace",
+ "textSigle",
+ "docSigle",
+ "corpusSigle",
+ "textType",
+ "textTypeArt",
+ "textTypeRef",
+ "textColumn",
+ "textDomain",
+ "availability",
+ "language",
+ "corpusID", // Deprecated!
+ "ID" // Deprecated!
+ ));
+
+ private static HashSet<String> legacyTextFields =
+ new HashSet<String>(Arrays.asList(
+ "author",
+ "title",
+ "subTitle",
+ "corpusTitle",
+ "corpusSubTitle",
+ "corpusAuthor",
+ "docTitle",
+ "docSubTitle",
+ "docAuthor"
+ ));
+
+ private static HashSet<String> legacyKeywordsFields =
+ new HashSet<String>(Arrays.asList(
+ "textClass",
+ "foundries",
+ "keywords"
+ ));
+
+ private static HashSet<String> legacyStoredFields =
+ new HashSet<String>(Arrays.asList(
+ "docEditor",
+ "tokenSource",
+ "layerInfos",
+ "publisher",
+ "editor",
+ "fileEditionStatement",
+ "biblEditionStatement",
+ "reference",
+ "corpusEditor"
+ ));
+
+ private static HashSet<String> legacyDateFields =
+ new HashSet<String>(Arrays.asList(
+ "pubDate",
+ "creationDate"
+ ));
+
+
+
@JsonIgnore
public int internalDocID, localDocID, UID;
- // private HashMap<String, String> fieldMap;
-
@JsonIgnore
public MetaFieldsExt mFields = new MetaFieldsExt();
@@ -83,97 +139,56 @@
public void populateFields (Document doc, Collection<String> fields) {
// Remember - never serialize "tokens"
- // LEGACY
- if (fields.contains("corpusID"))
- this.setCorpusID(doc.get("corpusID"));
- if (fields.contains("ID"))
- this.setID(doc.get("ID"));
+ // TODO:
+ // Pupulate based on field types!
- // valid
if (fields.contains("UID"))
this.setUID(doc.get("UID"));
- if (fields.contains("author"))
- this.setAuthor(doc.get("author"));
- if (fields.contains("textClass"))
- this.setTextClass(doc.get("textClass"));
- if (fields.contains("title"))
- this.setTitle(doc.get("title"));
- if (fields.contains("subTitle"))
- this.setSubTitle(doc.get("subTitle"));
- if (fields.contains("pubDate"))
- this.setPubDate(doc.get("pubDate"));
- if (fields.contains("pubPlace"))
- this.setPubPlace(doc.get("pubPlace"));
- // Temporary (later meta fields in term vector)
- if (fields.contains("foundries"))
- this.setFoundries(doc.get("foundries"));
+ String field;
+ Iterator<String> i = legacyTextFields.iterator();
+ while (i.hasNext()) {
+ field = i.next();
+ if (fields.contains(field)) {
+ this.addText(field, doc.get(field));
+ };
+ };
- // New fields
- if (fields.contains("textSigle"))
- this.setTextSigle(doc.get("textSigle"));
- if (fields.contains("docSigle"))
- this.setDocSigle(doc.get("docSigle"));
- if (fields.contains("corpusSigle"))
- this.setCorpusSigle(doc.get("corpusSigle"));
- if (fields.contains("layerInfos"))
- this.setLayerInfos(doc.get("layerInfos"));
- if (fields.contains("tokenSource"))
- this.setTokenSource(doc.get("tokenSource"));
- if (fields.contains("editor"))
- this.setEditor(doc.get("editor"));
+ i = legacyKeywordsFields.iterator();
+ while (i.hasNext()) {
+ field = i.next();
+ if (fields.contains(field)) {
+ this.addKeywords(field, doc.get(field));
+ };
+ };
- if (fields.contains("corpusAuthor"))
- this.setCorpusAuthor(doc.get("corpusAuthor"));
- if (fields.contains("corpusEditor"))
- this.setCorpusEditor(doc.get("corpusEditor"));
- if (fields.contains("corpusTitle"))
- this.setCorpusTitle(doc.get("corpusTitle"));
- if (fields.contains("corpusSubTitle"))
- this.setCorpusSubTitle(doc.get("corpusSubTitle"));
+ i = legacyStoredFields.iterator();
+ while (i.hasNext()) {
+ field = i.next();
+ if (fields.contains(field)) {
+ this.addStored(field, doc.get(field));
+ };
+ };
- if (fields.contains("docAuthor"))
- this.setDocAuthor(doc.get("docAuthor"));
- if (fields.contains("docEditor"))
- this.setDocEditor(doc.get("docEditor"));
- if (fields.contains("docTitle"))
- this.setDocTitle(doc.get("docTitle"));
- if (fields.contains("docSubTitle"))
- this.setDocSubTitle(doc.get("docSubTitle"));
+ i = legacyStringFields.iterator();
+ while (i.hasNext()) {
+ field = i.next();
+ if (fields.contains(field)) {
+ this.addString(field, doc.get(field));
+ };
+ };
- if (fields.contains("publisher"))
- this.setPublisher(doc.get("publisher"));
- if (fields.contains("reference"))
- this.setReference(doc.get("reference"));
- if (fields.contains("creationDate"))
- this.setCreationDate(doc.get("creationDate"));
- if (fields.contains("keywords"))
- this.setKeywords(doc.get("keywords"));
- if (fields.contains("textClass"))
- this.setTextClass(doc.get("textClass"));
- if (fields.contains("textColumn"))
- this.setTextColumn(doc.get("textColumn"));
- if (fields.contains("textDomain"))
- this.setTextDomain(doc.get("textDomain"));
- if (fields.contains("textType"))
- this.setTextType(doc.get("textType"));
- if (fields.contains("textTypeArt"))
- this.setTextTypeArt(doc.get("textTypeArt"));
- if (fields.contains("textTypeRef"))
- this.setTextTypeRef(doc.get("textTypeRef"));
- if (fields.contains("language"))
- this.setLanguage(doc.get("language"));
-
- if (fields.contains("biblEditionStatement"))
- this.setBiblEditionStatement(doc.get("biblEditionStatement"));
- if (fields.contains("fileEditionStatement"))
- this.setFileEditionStatement(doc.get("fileEditionStatement"));
-
+ i = legacyDateFields.iterator();
+ while (i.hasNext()) {
+ field = i.next();
+ if (fields.contains(field)) {
+ this.addDate(field, doc.get(field));
+ };
+ };
+
// Legacy
if (fields.contains("license"))
- this.setAvailability(doc.get("license"));
- else if (fields.contains("availability"))
- this.setAvailability(doc.get("availability"));
+ this.addString("availability", doc.get("license"));
};
@@ -191,7 +206,6 @@
*/
public void populateDocument (Document doc, String field,
Collection<String> fields) {
- // this.setField(field);
this.setPrimaryData(doc.get(field));
this.populateFields(doc, fields);
};
@@ -233,20 +247,6 @@
/**
- * Set the publication date of the document.
- *
- * @param date
- * The date as a {@link KrillDate} compatible string
- * representation.
- * @return A {@link KrillDate} object for chaining.
- */
- @JsonProperty("pubDate")
- public void setPubDate (String pubDate) {
- this.addDate("pubDate", pubDate);
- };
-
-
- /**
* Get the creation date of the document
* as a {@link KrillDate} object.
*
@@ -282,33 +282,6 @@
/**
- * Set the creation date of the document.
- *
- * @param date
- * The date as a {@link KrillDate} compatible string
- * representation.
- * @return A {@link KrillDate} object for chaining.
- */
- @JsonProperty("creationDate")
- public void setCreationDate (String creationDate) {
- this.addDate("creationDate", creationDate);
- };
-
-
- /**
- * Set the creation date of the document.
- *
- * @param date
- * The date as a {@link KrillDate} object.
- * @return A {@link KrillDate} object for chaining.
- */
- /*
- public KrillDate setCreationDate (KrillDate date) {
- return (this.creationDate = date);
- };
- */
-
- /**
* Get the name of the author of the document.
*
* @return The name of the author as a string.
@@ -317,18 +290,7 @@
return this.getFieldValue("author");
};
-
- /**
- * Set the name of the author of the document.
- *
- * @param author
- * The name of the author as a string.
- */
- public void setAuthor (String author) {
- this.addText("author", author);
- };
-
-
+
/**
* Get the text class of the document.
*
@@ -340,17 +302,6 @@
/**
- * Set the text class of the document.
- *
- * @param textClass
- * The text class of the document as a string.
- */
- public void setTextClass (String textClass) {
- this.addKeywords("textClass", textClass);
- };
-
-
- /**
* Get the publication place of the document.
*
* @return The publication place of the document as a string.
@@ -361,17 +312,6 @@
/**
- * Set the publication place of the document.
- *
- * @param pubPlace
- * The publication place of the document as a string.
- */
- public void setPubPlace (String pubPlace) {
- this.addString("pubPlace", pubPlace);
- };
-
-
- /**
* Get the unique identifier of the document.
*
* @return The unique identifier of the document as an integer.
@@ -425,17 +365,6 @@
/**
- * Set the title of the document.
- *
- * @param title
- * The title of the document as a string.
- */
- public void setTitle (String title) {
- this.addText("title", title);
- };
-
-
- /**
* Get the subtitle of the document.
*
* @return The subtitle of the document as a string.
@@ -446,17 +375,6 @@
/**
- * Set the subtitle of the document.
- *
- * @param subTitle
- * The subtitle of the document as a string.
- */
- public void setSubTitle (String subTitle) {
- this.addText("subTitle", subTitle);
- };
-
-
- /**
* Get the primary data of the document.
*
* @return The primary data of the document as a string.
@@ -539,18 +457,6 @@
/**
- * Set information on the foundries the document
- * is annotated with.
- *
- * @param foundries
- * The foundry information string.
- */
- public void setFoundries (String foundries) {
- this.addKeywords("foundries", foundries);
- };
-
-
- /**
* Get information on the layers the document
* is annotated with as a string.
*
@@ -561,18 +467,6 @@
};
- /**
- * Set information on the layers the document
- * is annotated with as a string.
- *
- * @param layerInfos
- * The layer information string.
- */
- public void setLayerInfos (String layerInfos) {
- this.addStored("layerInfos", layerInfos);
- };
-
-
// This is the new text id
/**
* Get the text sigle as a string.
@@ -584,18 +478,6 @@
};
- // This is the new text id
- /**
- * Set the text sigle as a string.
- *
- * @param textSigle
- * The text sigle as a string.
- */
- public void setTextSigle (String textSigle) {
- this.addString("textSigle", textSigle);
- };
-
-
// This is the new corpus id
/**
* Get the corpus sigle as a string.
@@ -607,18 +489,6 @@
};
- // This is the new corpus id
- /**
- * Set the corpus sigle as a string.
- *
- * @param corpusSigle
- * The corpus sigle as a string.
- */
- public void setCorpusSigle (String corpusSigle) {
- this.addString("corpusSigle", corpusSigle);
- };
-
-
/**
* Get the document sigle as a string.
*
@@ -630,17 +500,6 @@
/**
- * Set the document sigle as a string.
- *
- * @param docSigle
- * The document sigle as a string.
- */
- public void setDocSigle (String docSigle) {
- this.addString("docSigle", docSigle);
- };
-
-
- /**
* Get the name of the publisher as a string.
*
* @return The name of the publisher as a string.
@@ -651,17 +510,6 @@
/**
- * Set the name of the publisher as a string.
- *
- * @param publisher
- * The name of the publisher as a string.
- */
- public void setPublisher (String publisher) {
- this.addStored("publisher", publisher);
- };
-
-
- /**
* Get the name of the editor as a string.
*
* @return The name of the editor as a string.
@@ -670,17 +518,6 @@
return this.getFieldValue("editor");
};
-
- /**
- * Set the name of the editor as a string.
- *
- * @param editor
- * The name of the editor as a string.
- */
- public void setEditor (String editor) {
- this.addStored("editor", editor);
- };
-
/**
* Get the type of the text as a string.
@@ -693,17 +530,6 @@
/**
- * Set the type of the text as a string.
- *
- * @param textType
- * The type of the text as a string.
- */
- public void setTextType (String textType) {
- this.addString("textType", textType);
- };
-
-
- /**
* Get the type art of the text as a string.
*
* @return The type art of the text as a string.
@@ -712,29 +538,6 @@
return this.getFieldValue("textTypeArt");
};
-
- /**
- * Set the type art of the text as a string.
- *
- * @param textTypeArt
- * The type art of the text as a string.
- */
- public void setTextTypeArt (String textTypeArt) {
- this.addString("textTypeArt", textTypeArt);
- };
-
-
- /**
- * Set the type reference of the text as a string.
- *
- * @param textTypeRef
- * The type reference of the text as a string.
- */
- public void setTextTypeRef (String textTypeRef) {
- this.addString("textTypeRef", textTypeRef);
- };
-
-
/**
* Get the type reference of the text as a string.
*
@@ -756,17 +559,6 @@
/**
- * Set the column of the text as a string.
- *
- * @param textColumn
- * The column of the text as a string.
- */
- public void setTextColumn (String textColumn) {
- this.addString("textColumn", textColumn);
- };
-
-
- /**
* Get the domain of the text as a string.
*
* @return The domain of the text as a string.
@@ -776,17 +568,6 @@
};
- /**
- * Set the domain of the text as a string.
- *
- * @param textDomain
- * The domain of the text as a string.
- */
- public void setTextDomain (String textDomain) {
- this.addString("textDomain", textDomain);
- };
-
-
/**
* Get the availability of the text as a string.
*
@@ -795,30 +576,6 @@
public String getAvailability () {
return this.getFieldValue("availability");
};
-
-
- /**
- * Set the availability of the text as a string.
- *
- * @param availability
- * The availability of the text as a string.
- */
- public void setAvailability (String availability) {
- this.addString("availability", availability);
- };
-
-
- /**
- * Set the license of the text as a string.
- * This is a deprecated alias to setAvailability.
- *
- * @param license
- * The license of the text as a string.
- */
- @Deprecated
- public void setLicense (String license) {
- this.setAvailability(license);
- };
/**
@@ -832,18 +589,6 @@
/**
- * Set the file edition statement of the text as a string.
- *
- * @param fileEditionStatement
- * The file edition statement
- * of the text as a string.
- */
- public void setFileEditionStatement (String fileEditionStatement) {
- this.addStored("fileEditionStatement", fileEditionStatement);
- };
-
-
- /**
* Get the bibliograhic edition statement of the text as a string.
*
* @return The bibliograhic edition statement of the text as a
@@ -855,18 +600,6 @@
/**
- * Set the bibliograhic edition statement of the text as a string.
- *
- * @param biblEditionStatement
- * The bibliograhic edition statement
- * of the text as a string.
- */
- public void setBiblEditionStatement (String biblEditionStatement) {
- this.addStored("biblEditionStatement", biblEditionStatement);
- };
-
-
- /**
* Get the reference of the text as a string.
*
* @return The reference of the text as a string.
@@ -877,17 +610,6 @@
/**
- * Set the reference of the text as a string.
- *
- * @param reference
- * The reference of the text as a string.
- */
- public void setReference (String reference) {
- this.addStored("reference", reference);
- };
-
-
- /**
* Get the language of the text as a string.
*
* @return The language of the text as a string.
@@ -898,17 +620,6 @@
/**
- * Set the language of the text as a string.
- *
- * @param language
- * The language of the text as a string.
- */
- public void setLanguage (String language) {
- this.addString("language", language);
- };
-
-
- /**
* Get the corpus title of the text as a string.
*
* @return The corpus title of the text as a string.
@@ -919,17 +630,6 @@
/**
- * Set the corpus title of the text as a string.
- *
- * @param corpusTitle
- * The corpus title of the text as a string.
- */
- public void setCorpusTitle (String corpusTitle) {
- this.addText("corpusTitle", corpusTitle);
- };
-
-
- /**
* Get the corpus subtitle of the text as a string.
*
* @return The corpus subtitle of the text as a string.
@@ -940,18 +640,6 @@
/**
- * Set the corpus subtitle of the text as a string.
- *
- * @param corpusSubTitle
- * The corpus subtitle of the
- * text as a string.
- */
- public void setCorpusSubTitle (String corpusSubTitle) {
- this.addText("corpusSubTitle", corpusSubTitle);
- };
-
-
- /**
* Get the corpus author of the text as a string.
*
* @return The corpus author of the text as a string.
@@ -962,16 +650,6 @@
/**
- * Set the corpus author of the text as a string.
- *
- * @return The corpus author of the text as a string.
- */
- public void setCorpusAuthor (String corpusAuthor) {
- this.addText("corpusAuthor", corpusAuthor);
- };
-
-
- /**
* Get the corpus editor of the text as a string.
*
* @return The corpus editor of the text as a string.
@@ -982,17 +660,6 @@
/**
- * Set the corpus editor of the text as a string.
- *
- * @param corpusEditor
- * The corpus editor of the text as a string.
- */
- public void setCorpusEditor (String corpusEditor) {
- this.addStored("corpusEditor", corpusEditor);
- };
-
-
- /**
* Get the document title of the text as a string.
*
* @return The document title of the text as a string.
@@ -1003,17 +670,6 @@
/**
- * Set the document title of the text as a string.
- *
- * @param docTitle
- * The document title of the text as a string.
- */
- public void setDocTitle (String docTitle) {
- this.addText("docTitle", docTitle);
- };
-
-
- /**
* Get the subtitle of the document of the text as a string.
*
* @return The subtitle of the document of the text as a string.
@@ -1024,18 +680,6 @@
/**
- * Set the subtitle of the document of the text as a string.
- *
- * @param docSubTitle
- * The subtitle of the document of the
- * text as a string.
- */
- public void setDocSubTitle (String docSubTitle) {
- this.addText("docSubTitle", docSubTitle);
- };
-
-
- /**
* Get the author of the document of the text as a string.
*
* @return The author of the document of the text as a string.
@@ -1046,17 +690,6 @@
/**
- * Set the author of the document of the text as a string.
- *
- * @param docAuthor
- * The author of the document of the text as a string.
- */
- public void setDocAuthor (String docAuthor) {
- this.addText("docAuthor", docAuthor);
- };
-
-
- /**
* Get the editor of the document of the text as a string.
*
* @return The editor of the document of the text as a string.
@@ -1067,17 +700,6 @@
/**
- * Set the editor of the document of the text as a string.
- *
- * @param docEditor
- * The editor of the document of the text as a string.
- */
- public void setDocEditor (String docEditor) {
- this.addStored("docEditor", docEditor);
- };
-
-
- /**
* Get the keywords of the text as a string.
*
* @return The keywords of the text as a string.
@@ -1086,18 +708,6 @@
return this.getFieldValue("keywords");
};
-
- /**
- * Set the keywords of the text as a string.
- *
- * @param keywords
- * The keywords of the text as a string.
- */
- public void setKeywords (String keywords) {
- this.addKeywords("keywords", keywords);
- };
-
-
/**
* Get information about the source of tokenization
* as a string.
@@ -1108,44 +718,60 @@
return this.getFieldValue("tokenSource");
};
-
- /**
- * Set information about the source of tokenization
- * as a string.
- *
- * @param tokenSource
- * The tokenization information as a string.
- */
- public void setTokenSource (String tokenSource) {
- this.addStored("tokenSource", tokenSource);
- };
-
-
@Deprecated
@JsonProperty("corpusID")
public String getCorpusID () {
return this.getFieldValue("corpusID");
};
-
- @Deprecated
- public void setCorpusID (String corpusID) {
- this.addString("corpusID", corpusID);
- };
-
-
@Deprecated
@JsonProperty("ID")
public String getID () {
return this.getFieldValue("ID");
};
+ @JsonAnySetter
+ public void setLegacyMetaField (String name, JsonNode value) {
+
+ // Treat legacy string fields
+ if (legacyStringFields.contains(name)) {
+ this.addString(name, value.asText());
+ }
- @Deprecated
- public void setID (String ID) {
- this.addString("ID", ID);
+ // Treat legacy text fields
+ else if (legacyTextFields.contains(name)) {
+ this.addText(name, value.asText());
+ }
+
+ // Treat legacy keyword fields
+ else if (legacyKeywordsFields.contains(name)) {
+ this.addKeywords(name, value.asText());
+ }
+
+ // Treat legacy stored fields
+ else if (legacyStoredFields.contains(name)) {
+ this.addStored(name, value.asText());
+ }
+
+ // Treat legacy date fields
+ else if (legacyDateFields.contains(name)) {
+ this.addDate(name, value.asText());
+ }
+
+ else if (name.equals("license")) {
+ this.addString("availability", value.asText());
+ }
+
+ // Temporarily - treat legacy store values introduced for Sgbr
+ else if (name.equals("store")) {
+ // TODO: Store all values
+ };
+ //
+ // else {
+ // System.err.println("Unknown field: " + name);
+ // };
};
-
+
/**
* Serialize response as a {@link JsonNode}.
diff --git a/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java b/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java
index 5334d61..8d96d5c 100644
--- a/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java
+++ b/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java
@@ -69,7 +69,7 @@
public Document doc = new Document();
private FieldType tvField = new FieldType(TextField.TYPE_STORED);
private FieldType tvNoField = new FieldType(TextField.TYPE_NOT_STORED);
- private FieldType keywords = new FieldType(TextField.TYPE_STORED);
+ private FieldType keywordField = new FieldType(TextField.TYPE_STORED);
{
tvField.setStoreTermVectors(true);
@@ -82,8 +82,8 @@
tvNoField.setStoreTermVectorPayloads(true);
tvNoField.setStoreTermVectorOffsets(false);
- keywords.setStoreTermVectors(false);
- keywords.setIndexOptions(IndexOptions.DOCS_AND_FREQS);
+ keywordField.setStoreTermVectors(false);
+ keywordField.setIndexOptions(IndexOptions.DOCS_AND_FREQS);
};
@@ -139,7 +139,7 @@
)
);
- doc.add(new Field(key, value, keywords));
+ doc.add(new Field(key, value, keywordField));
};
@Override
@@ -269,15 +269,18 @@
// Get foundry info
if (node.containsKey("foundries"))
- this.setFoundries((String) node.get("foundries"));
+ this.addKeywords(
+ "foundries",
+ (String) node.get("foundries")
+ );
// Get layer info
if (node.containsKey("layerInfos"))
- this.setLayerInfos((String) node.get("layerInfos"));
+ this.addStored("layerInfos", (String) node.get("layerInfos"));
// Get tokenSource info
if (node.containsKey("tokenSource"))
- this.setTokenSource((String) node.get("tokenSource"));
+ this.addStored("tokenSource", (String) node.get("tokenSource"));
};
@@ -386,7 +389,7 @@
if (field.containsKey("foundries")) {
// TODO: Do not store positions!
String foundries = (String) field.get("foundries");
- this.setFoundries(foundries);
+ this.addKeywords("foundries", foundries);
};
this.addTV(fieldName, this.getPrimaryData(), mtts);
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 1beee5a..986ad11 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Match.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Match.java
@@ -200,11 +200,11 @@
this.mirrorIdentifier = id.toString();
if (id.getTextSigle() != null)
- this.setTextSigle(id.getTextSigle());
+ this.addString("textSigle", id.getTextSigle());
// <legacy>
- this.setCorpusID(id.getCorpusID());
- this.setDocID(id.getDocID());
+ this.addString("corpusID", id.getCorpusID());
+ this.addString("ID", id.getDocID());
// </legacy>
this.setStartPos(id.getStartPos());
@@ -526,17 +526,6 @@
return this.endPage;
};
-
- /**
- * Set document id.
- *
- * @param id
- * String representation of document ID.
- */
- public void setDocID (String id) {
- super.setID(id);
- };
-
/**
* Get the positional start offset of the match.
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestKrillDocument.java b/src/test/java/de/ids_mannheim/korap/index/TestKrillDocument.java
index b81c489..34b7421 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestKrillDocument.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestKrillDocument.java
@@ -26,18 +26,18 @@
@Test
public void createDocument () throws IOException {
KrillRealDocument krd = new KrillRealDocument();
- krd.setPubDate("2014-10-12");
+ krd.addDate("pubDate", "2014-10-12");
assertEquals("20141012", krd.getPubDate().toString());
assertEquals("2014-10-12", krd.getPubDateString());
- krd.setCreationDate("2012-09-05");
+ krd.addDate("creationDate", "2012-09-05");
assertEquals("20120905", krd.getCreationDate().toString());
assertEquals("2012-09-05", krd.getCreationDateString());
- krd.setAuthor("Stephen King");
+ krd.addText("author", "Stephen King");
assertEquals("Stephen King", krd.getAuthor());
- krd.setPubPlace("Düsseldorf");
+ krd.addString("pubPlace","Düsseldorf");
assertEquals("Düsseldorf", krd.getPubPlace());
krd.setUID(415);
@@ -52,10 +52,10 @@
catch (NumberFormatException e) {};
assertEquals(561, krd.getUID());
- krd.setTitle("An Example");
+ krd.addText("title", "An Example");
assertEquals("An Example", krd.getTitle());
- krd.setSubTitle("An Example");
+ krd.addText("subTitle", "An Example");
assertEquals("An Example", krd.getSubTitle());
krd.setPrimaryData("We don't need no education");
@@ -69,37 +69,37 @@
krd.setPrimaryData("öäüß");
assertEquals(4, krd.getPrimaryDataLength());
- krd.setTextSigle("U-abc-001");
+ krd.addString("textSigle", "U-abc-001");
assertEquals("U-abc-001", krd.getTextSigle());
- krd.setDocSigle("U-abc");
+ krd.addString("docSigle", "U-abc");
assertEquals("U-abc", krd.getDocSigle());
- krd.setCorpusSigle("U");
+ krd.addString("corpusSigle", "U");
assertEquals("U", krd.getCorpusSigle());
- krd.setPublisher("Pope Francis");
+ krd.addStored("publisher", "Pope Francis");
assertEquals("Pope Francis", krd.getPublisher());
- krd.setEditor("Michael Knight");
+ krd.addStored("editor", "Michael Knight");
assertEquals("Michael Knight", krd.getEditor());
- krd.setTextType("shortstory");
+ krd.addString("textType", "shortstory");
assertEquals("shortstory", krd.getTextType());
- krd.setTextTypeArt("Reportage");
+ krd.addString("textTypeArt", "Reportage");
assertEquals("Reportage", krd.getTextTypeArt());
- krd.setTextTypeRef("Hm");
+ krd.addString("textTypeRef", "Hm");
assertEquals("Hm", krd.getTextTypeRef());
- krd.setTextColumn("Feuilleton");
+ krd.addString("textColumn", "Feuilleton");
assertEquals("Feuilleton", krd.getTextColumn());
- krd.setTextDomain("Comment");
+ krd.addString("textDomain", "Comment");
assertEquals("Comment", krd.getTextDomain());
- krd.setAvailability("cc");
+ krd.addString("availability", "cc");
assertEquals("cc", krd.getAvailability());
/*
@@ -107,37 +107,37 @@
assertEquals("56-78", krd.getPages());
*/
- krd.setFileEditionStatement("no problemo 1");
+ krd.addStored("fileEditionStatement", "no problemo 1");
assertEquals("no problemo 1", krd.getFileEditionStatement());
- krd.setBiblEditionStatement("no problemo 2");
+ krd.addStored("biblEditionStatement", "no problemo 2");
assertEquals("no problemo 2", krd.getBiblEditionStatement());
- krd.setLanguage("de");
+ krd.addString("language", "de");
assertEquals("de", krd.getLanguage());
- krd.setCorpusTitle("Mannheimer Morgen");
+ krd.addText("corpusTitle", "Mannheimer Morgen");
assertEquals("Mannheimer Morgen", krd.getCorpusTitle());
- krd.setCorpusSubTitle("Zeitung für Mannheim");
+ krd.addText("corpusSubTitle", "Zeitung für Mannheim");
assertEquals("Zeitung für Mannheim", krd.getCorpusSubTitle());
- krd.setCorpusAuthor("Peter Gabriel");
+ krd.addText("corpusAuthor", "Peter Gabriel");
assertEquals("Peter Gabriel", krd.getCorpusAuthor());
- krd.setCorpusEditor("Phil Collins");
+ krd.addStored("corpusEditor", "Phil Collins");
assertEquals("Phil Collins", krd.getCorpusEditor());
- krd.setDocTitle("New York Times");
+ krd.addText("docTitle", "New York Times");
assertEquals("New York Times", krd.getDocTitle());
- krd.setDocSubTitle("Newspaper for New York");
+ krd.addText("docSubTitle", "Newspaper for New York");
assertEquals("Newspaper for New York", krd.getDocSubTitle());
- krd.setDocAuthor("Dean Baquet");
+ krd.addText("docAuthor", "Dean Baquet");
assertEquals("Dean Baquet", krd.getDocAuthor());
- krd.setDocEditor("Arthur Ochs Sulzberger Jr.");
+ krd.addText("docEditor", "Arthur Ochs Sulzberger Jr.");
assertEquals("Arthur Ochs Sulzberger Jr.", krd.getDocEditor());
};
};
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestKrillIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestKrillIndex.java
index 2e44f61..fd44110 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestKrillIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestKrillIndex.java
@@ -162,12 +162,12 @@
KrillIndex ki = new KrillIndex();
FieldDocument fd = new FieldDocument();
- fd.setTitle("Peter");
+ fd.addText("title", "Peter");
fd.setUID(22);
ki.addDoc(fd);
fd = new FieldDocument();
- fd.setTitle("Akron");
+ fd.addText("title", "Akron");
fd.setUID("05678");
ki.addDoc(fd);