summaryrefslogtreecommitdiff
path: root/test/java/net
diff options
context:
space:
mode:
authorluccioman <luccioman@users.noreply.github.com>2018-05-13 10:29:52 +0200
committerluccioman <luccioman@users.noreply.github.com>2018-05-13 10:29:52 +0200
commite357ade47d116c9b65b413666e467f9826dbeb9b (patch)
tree552177c13de66a8df430c9637aea5f420031f5e8 /test/java/net
parente115e57cc7a3bb34406656a701f33f013380691c (diff)
Reduced memory footprint of text snippet extraction
By not parsing and storing at first all sentences of a document, but only on the fly the ones necessary to compute the snippet.
Diffstat (limited to 'test/java/net')
-rw-r--r--test/java/net/yacy/search/snippet/TextSnippetTest.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/test/java/net/yacy/search/snippet/TextSnippetTest.java b/test/java/net/yacy/search/snippet/TextSnippetTest.java
index f572ee0e2..2d12c5d24 100644
--- a/test/java/net/yacy/search/snippet/TextSnippetTest.java
+++ b/test/java/net/yacy/search/snippet/TextSnippetTest.java
@@ -88,8 +88,30 @@ public class TextSnippetTest {
for (String word : wordlist) {
assertTrue("testTextSnippet word included " + word, rstr.contains(word));
}
-
}
+
+ /**
+ * Test snippet extraction when only document title matches searched terms.
+ * @throws MalformedURLException when the test document URL is malformed. Should not happen.
+ */
+ @Test
+ public void testTextSnippetMatchTitle() throws MalformedURLException {
+ final URIMetadataNode testDoc = new URIMetadataNode(doc);
+ testDoc.addField(CollectionSchema.title.name(), "New test case title");
+ testDoc.addField(CollectionSchema.keywords.name(), "junit");
+ testDoc.addField(CollectionSchema.author.name(), "test author");
+ testDoc.addField(CollectionSchema.text_t.name(),
+ "A new testcase has been introduced. " + "It includes a few test lines but only title should match.");
+
+ final String querywords = "title";
+ final QueryGoal qg = new QueryGoal(querywords);
+
+ final TextSnippet ts = new TextSnippet(null, testDoc, qg.getIncludeWordsSet(), qg.getIncludeHashes(),
+ cacheStrategy, pre, snippetMaxLength, reindexing);
+ assertEquals("testTextSnippet Error Code: ", "", ts.getError());
+ assertTrue("Snippet line should be extracted from first text lines.",
+ ts.getLineRaw().startsWith("A new testcase has been introduced."));
+ }
/**
* Test of getLineMarked method, of class TextSnippet.