Removed deprecated methods from Krill class
Change-Id: I1338e81e8de41413c3ab6dc0c013e0690a29ab45
diff --git a/Changes b/Changes
index 83ccfa9..7a20529 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,8 @@
0.55.6 2016-06-08
- [bugfix] distance with key "t" uses default foundry (diewald)
- [cleanup] Renamed fromJson() to fromKoral() (diewald)
+ - [cleanup] Removed deprecated methods in Krill:
+ setSpanQuery(), getRequest() (diewald)
0.55.5 2016-05-02
- [performance] Changed to a dynamic window for sorting in FocusSpans (margaretha)
diff --git a/src/main/java/de/ids_mannheim/korap/Krill.java b/src/main/java/de/ids_mannheim/korap/Krill.java
index 964c10c..0531c63 100644
--- a/src/main/java/de/ids_mannheim/korap/Krill.java
+++ b/src/main/java/de/ids_mannheim/korap/Krill.java
@@ -330,55 +330,4 @@
public SpanQuery getSpanQuery () {
return this.spanQuery;
};
-
-
- /**
- * Set the SpanQuery by means of a {@link SpanQueryWrapper} object
- * (i.e. the internal correspandence to KoralQuery's query
- * object).
- *
- * <strong>Warning</strong>: SpanQueries may be lazy deserialized
- * in future versions of Krill, rendering this API obsolete.
- *
- * @param query
- * The {@link SpanQueryWrapper} to unwrap
- * the {@link SpanQuery} object.
- * @return The {@link Krill} object for chaining.
- */
- @Deprecated
- public Krill setSpanQuery (SpanQueryWrapper sqwi) {
- try {
- this.spanQuery = sqwi.toQuery();
- }
- catch (QueryException q) {
- this.addError(q.getErrorCode(), q.getMessage());
- };
- return this;
- };
-
-
- /**
- * Set the {@link SpanQuery} object
- * (i.e. the internal correspandence to KoralQuery's query
- * object).
- *
- * <strong>Warning</strong>: SpanQueries may be lazy deserialized
- * in future versions of Krill, rendering this API obsolete.
- *
- * @param query
- * The {@link SpanQuery} object.
- * @return The {@link Krill} object for chaining.
- */
- @Deprecated
- public Krill setSpanQuery (SpanQuery sq) {
- this.spanQuery = sq;
- return this;
- };
-
-
- // Requests are out - queries will be mirrored completely
- @Deprecated
- public JsonNode getRequest () {
- return this.request;
- };
};
diff --git a/src/main/java/de/ids_mannheim/korap/KrillQuery.java b/src/main/java/de/ids_mannheim/korap/KrillQuery.java
index d12e473..fb7ae74 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillQuery.java
@@ -137,6 +137,17 @@
/**
+ * The index field associated with
+ * the token stream.
+ */
+ public String getField () {
+ if (field == null)
+ return "tokens";
+ return this.field;
+ };
+
+
+ /**
* <p>Deserialize JSON-LD query to a {@link SpanQueryWrapper}
* object.</p>
*
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java
index bff6608..62f239a 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java
@@ -8,6 +8,7 @@
import org.junit.runners.JUnit4;
import de.ids_mannheim.korap.Krill;
+import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
import de.ids_mannheim.korap.KrillIndex;
import de.ids_mannheim.korap.query.QueryBuilder;
import de.ids_mannheim.korap.response.Result;
@@ -39,45 +40,44 @@
ki.commit();
QueryBuilder kq = new QueryBuilder("base");
- SpanQuery sq = kq.re("s:af*e").toQuery();
- assertEquals("SpanMultiTermQueryWrapper(base:/s:af*e/)", sq.toString());
+ SpanQueryWrapper sqw = kq.re("s:af*e");
+ assertEquals("SpanMultiTermQueryWrapper(base:/s:af*e/)", sqw.toQuery().toString());
- Krill ks = new Krill(sq);
- ks.getMeta().getContext().left.setToken(true).setLength(1);
- ks.getMeta().getContext().right.setToken(true).setLength(1);
-
+ Krill ks = _newKrill(sqw);
+
Result kr = ki.search(ks);
assertEquals((long) 2, kr.getTotalResults());
assertEquals("[affe] afffe ...", kr.getMatch(0).getSnippetBrackets());
assertEquals("affe [afffe] baum ...", kr.getMatch(1)
.getSnippetBrackets());
- kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:baum.*")
- .toQuery()));
+ ks = _newKrill(new QueryBuilder("base").re("s:baum.*"));
+ kr = ki.search(ks);
+
assertEquals((long) 2, kr.getTotalResults());
assertEquals("... afffe [baum] baumgarten ...", kr.getMatch(0)
- .getSnippetBrackets());
+ .getSnippetBrackets());
assertEquals("... baum [baumgarten] steingarten ...", kr.getMatch(1)
- .getSnippetBrackets());
+ .getSnippetBrackets());
- kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re(
- "s:.....?garten").toQuery()));
+ ks = _newKrill(new QueryBuilder("base").re("s:.....?garten"));
+ kr = ki.search(ks);
assertEquals((long) 2, kr.getTotalResults());
assertEquals("... baum [baumgarten] steingarten ...", kr.getMatch(0)
- .getSnippetBrackets());
+ .getSnippetBrackets());
assertEquals("... baumgarten [steingarten] franz ...", kr.getMatch(1)
- .getSnippetBrackets());
+ .getSnippetBrackets());
- kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:ha.s")
- .toQuery()));
+ ks = _newKrill(new QueryBuilder("base").re("s:ha.s"));
+ kr = ki.search(ks);
assertEquals((long) 2, kr.getTotalResults());
assertEquals("... franz [hans] haus ...", kr.getMatch(0)
.getSnippetBrackets());
assertEquals("... hans [haus] efeu ...", kr.getMatch(1)
.getSnippetBrackets());
- kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:.*ff.*")
- .toQuery()));
+ ks = _newKrill(new QueryBuilder("base").re("s:.*ff.*"));
+ kr = ki.search(ks);
assertEquals((long) 3, kr.getTotalResults());
assertEquals("[affe] afffe ...", kr.getMatch(0).getSnippetBrackets());
assertEquals("affe [afffe] baum ...", kr.getMatch(1)
@@ -85,7 +85,6 @@
assertEquals("... efeu [effe]", kr.getMatch(2).getSnippetBrackets());
};
-
@Test
public void indexWildcard () throws Exception {
KrillIndex ki = new KrillIndex();
@@ -110,12 +109,10 @@
ki.commit();
QueryBuilder kq = new QueryBuilder("base");
- SpanQuery sq = kq.wc("s:af*e").toQuery();
- assertEquals("SpanMultiTermQueryWrapper(base:s:af*e)", sq.toString());
+ SpanQueryWrapper sq = kq.wc("s:af*e");
+ assertEquals("SpanMultiTermQueryWrapper(base:s:af*e)", sq.toQuery().toString());
- Krill ks = new Krill(sq);
- ks.getMeta().getContext().left.setToken(true).setLength(1);
- ks.getMeta().getContext().right.setToken(true).setLength(1);
+ Krill ks = _newKrill(sq);
Result kr = ki.search(ks);
assertEquals((long) 2, kr.getTotalResults());
@@ -123,36 +120,37 @@
assertEquals("affe [afffe] baum ...", kr.getMatch(1)
.getSnippetBrackets());
- kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").wc("s:baum.*")
- .toQuery()));
+ ks = _newKrill(new QueryBuilder("base").wc("s:baum.*"));
+ kr = ki.search(ks);
+
assertEquals((long) 0, kr.getTotalResults());
- kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").wc("s:baum*")
- .toQuery()));
+ ks = _newKrill(new QueryBuilder("base").wc("s:baum*"));
+ kr = ki.search(ks);
assertEquals((long) 2, kr.getTotalResults());
assertEquals("... afffe [baum] baumgarten ...", kr.getMatch(0)
.getSnippetBrackets());
assertEquals("... baum [baumgarten] steingarten ...", kr.getMatch(1)
.getSnippetBrackets());
- kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").wc("s:*garten")
- .toQuery()));
+ ks = _newKrill(new QueryBuilder("base").wc("s:*garten"));
+ kr = ki.search(ks);
assertEquals((long) 2, kr.getTotalResults());
assertEquals("... baum [baumgarten] steingarten ...", kr.getMatch(0)
.getSnippetBrackets());
assertEquals("... baumgarten [steingarten] franz ...", kr.getMatch(1)
.getSnippetBrackets());
- kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").wc("s:ha?s")
- .toQuery()));
+ ks = _newKrill(new QueryBuilder("base").wc("s:ha?s"));
+ kr = ki.search(ks);
assertEquals((long) 2, kr.getTotalResults());
assertEquals("... franz [hans] haus ...", kr.getMatch(0)
.getSnippetBrackets());
assertEquals("... hans [haus] efeu ...", kr.getMatch(1)
.getSnippetBrackets());
- kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").wc("s:?ff?")
- .toQuery()));
+ ks = _newKrill(new QueryBuilder("base").wc("s:?ff?"));
+ kr = ki.search(ks);
assertEquals((long) 2, kr.getTotalResults());
assertEquals("[affe] afffe ...", kr.getMatch(0).getSnippetBrackets());
assertEquals("... efeu [effe]", kr.getMatch(1).getSnippetBrackets());
@@ -183,56 +181,57 @@
ki.commit();
QueryBuilder kq = new QueryBuilder("base");
- SpanQuery sq = kq.re("s:Af*e", true).toQuery();
- assertEquals("SpanMultiTermQueryWrapper(base:/i:af*e/)", sq.toString());
+ SpanQueryWrapper sqw = kq.re("s:Af*e", true);
+ assertEquals("SpanMultiTermQueryWrapper(base:/i:af*e/)", sqw.toQuery().toString());
- Krill ks = new Krill(sq);
- ks.getMeta().getContext().left.setToken(true).setLength(1);
- ks.getMeta().getContext().right.setToken(true).setLength(1);
-
+ Krill ks = _newKrill(sqw);
Result kr = ki.search(ks);
assertEquals((long) 2, kr.getTotalResults());
assertEquals("[AfFe] aFfFE ...", kr.getMatch(0).getSnippetBrackets());
assertEquals("AfFe [aFfFE] Baum ...", kr.getMatch(1)
.getSnippetBrackets());
- kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:Af.*e")
- .toQuery()));
+ ks = _newKrill(new QueryBuilder("base").re("s:Af.*e"));
+ kr = ki.search(ks);
assertEquals((long) 1, kr.getTotalResults());
assertEquals("[AfFe] aFfFE ...", kr.getMatch(0).getSnippetBrackets());
- kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:baum.*",
- true).toQuery()));
+ ks = _newKrill(new QueryBuilder("base").re("s:baum.*",
+ true));
+ kr = ki.search(ks);
assertEquals((long) 2, kr.getTotalResults());
assertEquals("... aFfFE [Baum] Baumgarten ...", kr.getMatch(0)
.getSnippetBrackets());
assertEquals("... Baum [Baumgarten] SteinGarten ...", kr.getMatch(1)
.getSnippetBrackets());
- kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re(
- "s:.*garten", true).toQuery()));
+ ks = _newKrill(new QueryBuilder("base").re(
+ "s:.*garten", true));
+ kr = ki.search(ks);
assertEquals((long) 2, kr.getTotalResults());
assertEquals("... Baum [Baumgarten] SteinGarten ...", kr.getMatch(0)
.getSnippetBrackets());
assertEquals("... Baumgarten [SteinGarten] franZ ...", kr.getMatch(1)
.getSnippetBrackets());
- kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re(
- "s:.*garten", false).toQuery()));
+ ks = _newKrill(new QueryBuilder("base").re("s:.*garten", false));
+ kr = ki.search(ks);
assertEquals((long) 1, kr.getTotalResults());
assertEquals("... Baum [Baumgarten] SteinGarten ...", kr.getMatch(0)
.getSnippetBrackets());
- kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:ha.s",
- true).toQuery()));
+ ks = _newKrill(new QueryBuilder("base").re("s:ha.s",
+ true));
+ kr = ki.search(ks);
assertEquals((long) 2, kr.getTotalResults());
assertEquals("... franZ [HaNs] Haus ...", kr.getMatch(0)
.getSnippetBrackets());
assertEquals("... HaNs [Haus] Efeu ...", kr.getMatch(1)
.getSnippetBrackets());
- kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:.*f*e",
- true).toQuery()));
+ ks = _newKrill(new QueryBuilder("base").re("s:.*f*e",
+ true));
+ kr = ki.search(ks);
assertEquals((long) 3, kr.getTotalResults());
assertEquals("[AfFe] aFfFE ...", kr.getMatch(0).getSnippetBrackets());
assertEquals("AfFe [aFfFE] Baum ...", kr.getMatch(1)
@@ -281,7 +280,6 @@
.getSnippetBrackets());
};
-
@Test
public void indexRegexWithinRewrite () throws Exception {
KrillIndex ki = new KrillIndex();
@@ -321,4 +319,11 @@
assertEquals("[affe afffe] baum ...", kr.getMatch(0)
.getSnippetBrackets());
};
+
+ private Krill _newKrill (SpanQueryWrapper query) {
+ Krill ks = new Krill(query);
+ ks.getMeta().getContext().left.setToken(true).setLength(1);
+ ks.getMeta().getContext().right.setToken(true).setLength(1);
+ return ks;
+ };
};