Merge "Adding availability to default fields in matchinfo"
diff --git a/Changes b/Changes
index b993062..88599ac 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,4 @@
-0.55.8 2017-05-05
+0.55.8 2017-05-29
         - [feature] Retrieve and display pagebreaks (diewald)
         - [bugfix] Handle invalid dates in input (diewald)
         - [feature] Support availability meta data (diewald)
diff --git a/src/main/java/de/ids_mannheim/korap/KrillIndex.java b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
index de66d50..b58ef0c 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillIndex.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
@@ -1074,11 +1074,17 @@
                 Terms docTerms = atomic.reader().getTermVector(localDocID,
                         field);
 
+				// The following fields should be lifted for the match
                 HashSet<String> fields = (HashSet<String>) new Krill().getMeta()
                         .getFields().clone();
 
+				// Lift primary field
                 fields.add(field);
 
+				// Lift all fields
+				if (fields.contains("@all"))
+					fields = null;
+
                 // Load the necessary fields of the document
                 Document doc = atomic.reader().document(localDocID, fields);
 
diff --git a/src/main/java/de/ids_mannheim/korap/KrillMeta.java b/src/main/java/de/ids_mannheim/korap/KrillMeta.java
index a6aaade..330cbdb 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillMeta.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillMeta.java
@@ -43,13 +43,25 @@
 
         // Lift following fields per default
         // These fields are chosen for <legacy /> reasons
-        for (String field : new String[] { "ID", "UID", "textSigle", "corpusID",
-                "author", "title", "subTitle", "textClass", "pubPlace",
-                "pubDate",
-                // "foundries",
+        for (String field : new String[] {
+				"ID",
+				"UID",
+				"textSigle",
+				"corpusID",
+				"author",
+				"title",
+				"subTitle",
+				"textClass",
+				"pubPlace",
+				"pubDate",
+				// "foundries",
                 // "tokenization",
                 // New:
-                "layerInfos", "docSigle", "corpusSigle", }) {
+                "availability",
+                "layerInfos",
+				"docSigle",
+				"corpusSigle"
+			}) {
             fields.add(field);
         };
 
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java b/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
index c208a3e..0500050 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
@@ -649,11 +649,23 @@
                 res.at("/snippet").asText());
     };
 
+	@Test
+    public void indexWithFieldInfo () throws IOException, QueryException {
+        KrillIndex ki = new KrillIndex();
+        ki.addDoc(createSimpleFieldDoc());
+        ki.commit();
+
+        Match km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8", "tokens",
+                null, null, false, false);
+		assertEquals(km.getAvailability(), "CC-BY-SA");
+    };
+
 
     private FieldDocument createSimpleFieldDoc () {
         FieldDocument fd = new FieldDocument();
         fd.addString("corpusID", "c1");
         fd.addString("ID", "d1");
+        fd.addString("availability", "CC-BY-SA");
         fd.addTV("tokens", "abcabcabac",
                 "[(0-1)s:a|i:a|f/m:eins|f/y:one|x/o:erstens|it/is:1|>:x/rel:a$<b>32<i>4<s>0<s>0<s>0|_0$<i>0<i>1|-:t$<i>10]"
                         + "[(1-2)s:b|i:b|f/m:zwei|f/y:two|x/o:zweitens|it/is:2|_1$<i>1<i>2]"