Merge branch 'master' of ssh://korap.ids-mannheim.de:29418/private/Kustvakt-core
diff --git a/pom.xml b/pom.xml
index 795fc83..b36529a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -142,7 +142,7 @@
<dependency>
<groupId>de.ids_mannheim.korap</groupId>
<artifactId>Koral</artifactId>
- <version>0.2</version>
+ <version>0.21</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
diff --git a/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java b/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java
index f5f339d..ff2b2cb 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java
@@ -61,6 +61,9 @@
return config.getDefault_lemma();
case "surface":
return config.getDefault_surface();
+ // refers to "structure" and is used for paragraphs or sentence boundaries
+ case "s":
+ return "base";
default:
// if the layer is not in this specific listing, assume a default layer
// like orth or other tokenization layers
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/LightService.java b/src/main/java/de/ids_mannheim/korap/web/service/LightService.java
index 9ae312b..6e54744 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/LightService.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/LightService.java
@@ -113,6 +113,7 @@
@QueryParam("count") Integer pageLength,
@QueryParam("offset") Integer pageIndex,
@QueryParam("page") Integer pageInteger,
+ @QueryParam("fields") Set<String> fields,
@QueryParam("cq") String cq, @QueryParam("engine") String engine) {
KustvaktConfiguration.BACKENDS eng = BeanConfiguration
.getConfiguration().chooseBackend(engine);
@@ -122,9 +123,8 @@
MetaQueryBuilder meta = QueryBuilderUtil
.defaultMetaBuilder(pageIndex, pageInteger, pageLength, ctx,
cutoff);
+ meta.addEntry("fields", fields);
serializer.setMeta(meta);
- // fixme: should only apply to CQL queries per default!
- // meta.addEntry("itemsPerResource", 1);
if (cq != null)
serializer.setCollection(cq);
@@ -241,7 +241,6 @@
return Response.ok(stats).build();
}
-
@GET
@Path("/corpus/{id}/{docid}/{rest}/matchInfo")
public Response getMatchInfo(@PathParam("id") String id,
diff --git a/src/test/java/MetaQueryBuilderTest.java b/src/test/java/MetaQueryBuilderTest.java
new file mode 100644
index 0000000..7b4c3aa
--- /dev/null
+++ b/src/test/java/MetaQueryBuilderTest.java
@@ -0,0 +1,45 @@
+import com.fasterxml.jackson.databind.JsonNode;
+import de.ids_mannheim.korap.query.serialize.MetaQueryBuilder;
+import de.ids_mannheim.korap.utils.JsonUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author hanl
+ * @date 26/06/2015
+ */
+public class MetaQueryBuilderTest {
+
+ private static Pattern p = Pattern
+ .compile("^/\\s*\\d+-(?:c(?:hars?)?|t(?:okens)?)$/");
+
+ private static Pattern p3 = Pattern
+ .compile("\\d+-(c(?:hars?)?|t(?:okens)?)?");
+
+ @Test
+ public void testRegex() {
+ Matcher m = p.matcher("1-tokens,2-chars");
+ while (m.find()) {
+ int size = m.groupCount();
+ System.out.println("FOUND ");
+ for (int i = 0; i < size; i++)
+ System.out.println("GROUP " + m.group(i));
+ }
+ }
+
+ @Test
+ public void testMetaBuilder() {
+ Set<String> f = new HashSet<>();
+ f.add("docID");
+ f.add("corpusID");
+ MetaQueryBuilder m = new MetaQueryBuilder();
+ m.addEntry("fields", f);
+ JsonNode n = JsonUtils.readTree(JsonUtils.toJSON(m.raw()));
+ Assert.assertEquals("[\"docID\",\"corpusID\"]", n.at("/fields").toString());
+ }
+}