| Nils Diewald | d732e54 | 2014-11-12 17:54:02 +0000 | [diff] [blame] | 1 | package de.ids_mannheim.korap.index; |
| 2 | |
| 3 | import static org.junit.Assert.assertEquals; |
| 4 | |
| 5 | import java.io.File; |
| 6 | import java.io.IOException; |
| 7 | import java.io.InputStream; |
| 8 | import java.util.Properties; |
| 9 | |
| 10 | import org.apache.lucene.index.Term; |
| 11 | import org.apache.lucene.search.spans.SpanQuery; |
| 12 | import org.apache.lucene.search.spans.SpanTermQuery; |
| 13 | import org.apache.lucene.store.MMapDirectory; |
| 14 | import org.junit.Test; |
| 15 | |
| 16 | import de.ids_mannheim.korap.*; |
| 17 | import de.ids_mannheim.korap.util.QueryException; |
| 18 | |
| 19 | public 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 Diewald | e1ecd5e | 2014-11-27 02:17:24 +0000 | [diff] [blame] | 42 | System.err.println(kr.toJsonString()); |
| Nils Diewald | d732e54 | 2014-11-12 17:54:02 +0000 | [diff] [blame] | 43 | assertEquals(8, kr.getTotalResults()); |
| 44 | }; |
| 45 | } |