blob: 070665e5951418ec8e8f3147662541a9d8d68dd9 [file] [log] [blame]
Nils Diewaldd732e542014-11-12 17:54:02 +00001package de.ids_mannheim.korap.index;
2
3import static org.junit.Assert.assertEquals;
4
5import java.io.File;
6import java.io.IOException;
7import java.io.InputStream;
8import java.util.Properties;
9
10import org.apache.lucene.index.Term;
11import org.apache.lucene.search.spans.SpanQuery;
12import org.apache.lucene.search.spans.SpanTermQuery;
13import org.apache.lucene.store.MMapDirectory;
14import org.junit.Test;
15
16import de.ids_mannheim.korap.*;
17import de.ids_mannheim.korap.util.QueryException;
18
19public class TestRealIndex {
20 KorapIndex ki;
21 KorapResult kr;
22 KorapSearch ks;
23 KorapQuery kq;
24
25 public TestRealIndex() throws IOException {
26 InputStream is = getClass().getResourceAsStream("/server.properties");
27 Properties prop = new Properties();
28 prop.load(is);
29
30 String indexPath = prop.getProperty("lucene.indexDir");
31 System.err.println(indexPath);
32 MMapDirectory md = new MMapDirectory(new File(indexPath));
33 ki = new KorapIndex(md);
34 };
35
36 @Test
37 public void testCase1() throws IOException, QueryException {
38 KorapQuery kq = new KorapQuery("tokens");
39 ks = new KorapSearch(kq.within(kq.tag("base/s:s"), kq.seq(kq.re("s:.*")).append(kq._(kq.re("s:.*")))).toQuery());
40 ks.setTimeOut(10000);
41 kr = ks.run(ki);
Nils Diewalde1ecd5e2014-11-27 02:17:24 +000042 System.err.println(kr.toJsonString());
Nils Diewaldd732e542014-11-12 17:54:02 +000043 assertEquals(8, kr.getTotalResults());
44 };
45}