Skip to content
Browse files

* added wildcard tests

  • Loading branch information...
1 parent 30b31ee commit 2a5f92ff337daadbb8204f73f5337aef801102b4 @whym committed May 7, 2012
Showing with 37 additions and 0 deletions.
  1. +37 −0 src/test/java/org/wikimedia/revdiffsearch/TestSearcherDaemon.java
View
37 src/test/java/org/wikimedia/revdiffsearch/TestSearcherDaemon.java
@@ -274,6 +274,43 @@ private static void phraseQuery(Analyzer analyzer) throws IOException, JSONExcep
system);
}
}
+
+ @Test public void operatorQueryWildcard() throws IOException, JSONException, InterruptedException {
+ Directory dir = new RAMDirectory();
+ IndexWriter writer = new IndexWriter(dir,
+ new IndexWriterConfig(Version.LUCENE_35,
+ new SimpleNGramAnalyzer(3)));
+ Indexer indexer = new Indexer(writer, 2, 2, 100);
+ indexer.indexDocuments(newTempFile("233192 10 0 'Accessiblecomputing' 980043141 u'*' False 99 u'RoseParks' 0:1:u'This subject covers\\n\\n* AssistiveTechnology\\n\\n* AccessibleSoftware\\n\\n* AccessibleWeb\\n\\n* LegalIssuesInAccessibleComputing\\n\\n'\n" +
+ "18201 12 0 'Anarchism' 1014649222 u'Automated conversion' True None u'Conversion script' 9230:1:u'[[talk:Anarchism|' 9252:1:u']]' 9260:1:u'[[Anarchism' 9276:1:u'|/Todo]]' 9292:1:u'talk:' 9304:-1:u'/Talk' 9464:1:u'\\n'\n" +
+ "12345 10 0 'Accessiblecomputing' 1980043141 u'*' False 99 u'Automated conversion' 0:1:u'[[fr:ABC]]\\n'"));
+ indexer.finish();
+
+ IndexSearcher searcher = new IndexSearcher(IndexReader.open(dir));
+ InetSocketAddress address = findFreeAddress();
+ new Thread(new SearcherDaemon(address, searcher, new QueryParser(Version.LUCENE_35, "added", new SimpleNGramAnalyzer(3)))).start();
+
+ Thread.sleep(1000L);
+
+ {
+ JSONObject q = new JSONObject();
+ q.put("q", "namespace:0 AND NOT \\[\\[?");
+ q.put("fields", "rev_id");
+ JSONObject json = retrieve(address, q);
+ System.err.println(json);//!
+ assertEquals(1, json.getInt("hits_all"));
+ Set<Integer> system = new HashSet<Integer>();
+ assertEquals(json.getJSONArray("hits").getJSONArray(0).getInt(0), 233192);
+ }
+ {
+ JSONObject q = new JSONObject();
+ q.put("q", "\\[\\[?");
+ q.put("fields", "rev_id");
+ JSONObject json = retrieve(address, q);
+ System.err.println(json);//!
+ assertEquals(2, json.getInt("hits_all"));
+ }
+ }
}
/*

0 comments on commit 2a5f92f

Please sign in to comment.
Something went wrong with that request. Please try again.