LUCENE-1563:Add example test case for surround query language

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@757762 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2009-03-24 12:28:13 +00:00
parent c6f7aa41a3
commit 126f4b18d3
2 changed files with 41 additions and 20 deletions

View File

@ -39,7 +39,7 @@ and(aa,bb,cc) aa and bb and cc
99n(aa,bb,cc) unordered span query with slop 98
20n(aa*,bb*)
3w(a?a or bb?, cc+)
3w(a?a or bb?, cc*)
title: text: aa
title : text : aa or bb
@ -64,12 +64,11 @@ not compared to Lucene's MultipleFieldQuery.
* suffix truncation is implemented very similar to Lucene's PrefixQuery.
Wildcards (? and internal *) are implemented with regular expressions
allow further variations. A reimplementation using
to allow further variations. A reimplementation using
WildCardTermEnum (correct name?) should be no problem.
Warnings about missing terms are sent to System.out, this might
be replaced by another stream.
be replaced by another stream, and tested for in the tests.
BooleanQueryTest.TestCollector uses a results checking method that should
BooleanQueryTst.TestCollector uses a results checking method that should
be replaced by the checking method from Lucene's TestBasics.java.

View File

@ -59,26 +59,15 @@ public class Test03Distance extends TestCase {
SingleFieldTestDb db1 = new SingleFieldTestDb(docs1, fieldName);
String[] docs2 = {
"w1 w2 w3 w4 w5",
"w1 w3 w2 w3",
""
};
SingleFieldTestDb db2 = new SingleFieldTestDb(docs2, fieldName);
public void distanceTest1(String query, int[] expdnrs) throws Exception {
BooleanQueryTst bqt = new BooleanQueryTst( query, expdnrs, db1, fieldName, this,
private void distanceTst(String query, int[] expdnrs, SingleFieldTestDb db) throws Exception {
BooleanQueryTst bqt = new BooleanQueryTst( query, expdnrs, db, fieldName, this,
new BasicQueryFactory(maxBasicQueries));
bqt.setVerbose(verbose);
bqt.doTest();
}
public void distanceTest2(String query, int[] expdnrs) throws Exception {
BooleanQueryTst bqt = new BooleanQueryTst( query, expdnrs, db2, fieldName, this,
new BasicQueryFactory(maxBasicQueries));
bqt.setVerbose(verbose);
bqt.doTest();
public void distanceTest1(String query, int[] expdnrs) throws Exception {
distanceTst(query, expdnrs, db1);
}
public void test0W01() throws Exception {
@ -182,6 +171,18 @@ public class Test03Distance extends TestCase {
public void test1Ntrunc09() throws Exception {
int[] expdnrs = {3}; distanceTest1( "(orda2 OR orda3) 2N (word2 OR worda3)", expdnrs);
}
String[] docs2 = {
"w1 w2 w3 w4 w5",
"w1 w3 w2 w3",
""
};
SingleFieldTestDb db2 = new SingleFieldTestDb(docs2, fieldName);
public void distanceTest2(String query, int[] expdnrs) throws Exception {
distanceTst(query, expdnrs, db2);
}
public void test2Wprefix01() throws Exception {
int[] expdnrs = {0}; distanceTest2( "W (w1, w2, w3)", expdnrs);
@ -217,4 +218,25 @@ public class Test03Distance extends TestCase {
public void test2Nnested02() throws Exception {
int[] expdnrs = {0,1}; distanceTest2( "w1 2N w2 2N w3", expdnrs);
}
String[] docs3 = {
"low pressure temperature inversion and rain",
"when the temperature has a negative height above a depression no precipitation gradient is expected",
"when the temperature has a negative height gradient above a depression no precipitation is expected",
""
};
SingleFieldTestDb db3 = new SingleFieldTestDb(docs3, fieldName);
public void distanceTest3(String query, int[] expdnrs) throws Exception {
distanceTst(query, expdnrs, db3);
}
public void test3Example01() throws Exception {
int[] expdnrs = {0,2}; // query does not match doc 1 because "gradient" is in wrong place there.
distanceTest3("50n((low w pressure*) or depression*,"
+ "5n(temperat*, (invers* or (negativ* 3n gradient*))),"
+ "rain* or precipitat*)",
expdnrs);
}
}