1 package org.apache.lucene.search.spans;
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 import org.apache.lucene.search.*;
24 * TestExplanations subclass focusing on span queries
26 public class TestSpanExplanations extends TestExplanations {
28 /* simple SpanTermQueries */
30 public void testST1() throws Exception {
31 SpanQuery q = st("w1");
32 qtest(q, new int[] {0,1,2,3});
34 public void testST2() throws Exception {
35 SpanQuery q = st("w1");
37 qtest(q, new int[] {0,1,2,3});
39 public void testST4() throws Exception {
40 SpanQuery q = st("xx");
41 qtest(q, new int[] {2,3});
43 public void testST5() throws Exception {
44 SpanQuery q = st("xx");
46 qtest(q, new int[] {2,3});
49 /* some SpanFirstQueries */
51 public void testSF1() throws Exception {
52 SpanQuery q = sf(("w1"),1);
53 qtest(q, new int[] {0,1,2,3});
55 public void testSF2() throws Exception {
56 SpanQuery q = sf(("w1"),1);
58 qtest(q, new int[] {0,1,2,3});
60 public void testSF4() throws Exception {
61 SpanQuery q = sf(("xx"),2);
62 qtest(q, new int[] {2});
64 public void testSF5() throws Exception {
65 SpanQuery q = sf(("yy"),2);
66 qtest(q, new int[] { });
68 public void testSF6() throws Exception {
69 SpanQuery q = sf(("yy"),4);
71 qtest(q, new int[] {2});
74 /* some SpanOrQueries */
76 public void testSO1() throws Exception {
77 SpanQuery q = sor("w1","QQ");
78 qtest(q, new int[] {0,1,2,3});
80 public void testSO2() throws Exception {
81 SpanQuery q = sor("w1","w3","zz");
82 qtest(q, new int[] {0,1,2,3});
84 public void testSO3() throws Exception {
85 SpanQuery q = sor("w5","QQ","yy");
86 qtest(q, new int[] {0,2,3});
88 public void testSO4() throws Exception {
89 SpanQuery q = sor("w5","QQ","yy");
90 qtest(q, new int[] {0,2,3});
95 /* some SpanNearQueries */
97 public void testSNear1() throws Exception {
98 SpanQuery q = snear("w1","QQ",100,true);
99 qtest(q, new int[] {});
101 public void testSNear2() throws Exception {
102 SpanQuery q = snear("w1","xx",100,true);
103 qtest(q, new int[] {2,3});
105 public void testSNear3() throws Exception {
106 SpanQuery q = snear("w1","xx",0,true);
107 qtest(q, new int[] {2});
109 public void testSNear4() throws Exception {
110 SpanQuery q = snear("w1","xx",1,true);
111 qtest(q, new int[] {2,3});
113 public void testSNear5() throws Exception {
114 SpanQuery q = snear("xx","w1",0,false);
115 qtest(q, new int[] {2});
118 public void testSNear6() throws Exception {
119 SpanQuery q = snear("w1","w2","QQ",100,true);
120 qtest(q, new int[] {});
122 public void testSNear7() throws Exception {
123 SpanQuery q = snear("w1","xx","w2",100,true);
124 qtest(q, new int[] {2,3});
126 public void testSNear8() throws Exception {
127 SpanQuery q = snear("w1","xx","w2",0,true);
128 qtest(q, new int[] {2});
130 public void testSNear9() throws Exception {
131 SpanQuery q = snear("w1","xx","w2",1,true);
132 qtest(q, new int[] {2,3});
134 public void testSNear10() throws Exception {
135 SpanQuery q = snear("xx","w1","w2",0,false);
136 qtest(q, new int[] {2});
138 public void testSNear11() throws Exception {
139 SpanQuery q = snear("w1","w2","w3",1,true);
140 qtest(q, new int[] {0,1});
144 /* some SpanNotQueries */
146 public void testSNot1() throws Exception {
147 SpanQuery q = snot(sf("w1",10),st("QQ"));
148 qtest(q, new int[] {0,1,2,3});
150 public void testSNot2() throws Exception {
151 SpanQuery q = snot(sf("w1",10),st("QQ"));
153 qtest(q, new int[] {0,1,2,3});
155 public void testSNot4() throws Exception {
156 SpanQuery q = snot(sf("w1",10),st("xx"));
157 qtest(q, new int[] {0,1,2,3});
159 public void testSNot5() throws Exception {
160 SpanQuery q = snot(sf("w1",10),st("xx"));
162 qtest(q, new int[] {0,1,2,3});
164 public void testSNot7() throws Exception {
165 SpanQuery f = snear("w1","w3",10,true);
167 SpanQuery q = snot(f, st("xx"));
168 qtest(q, new int[] {0,1,3});
170 public void testSNot10() throws Exception {
171 SpanQuery t = st("xx");
173 SpanQuery q = snot(snear("w1","w3",10,true), t);
174 qtest(q, new int[] {0,1,3});