~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to lucene/backwards/src/test/org/apache/lucene/search/spans/TestSpanExplanations.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.apache.lucene.search.spans;
2
 
 
3
 
/**
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
10
 
 *
11
 
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 
 *
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.
18
 
 */
19
 
 
20
 
import org.apache.lucene.search.*;
21
 
 
22
 
 
23
 
/**
24
 
 * TestExplanations subclass focusing on span queries
25
 
 */
26
 
public class TestSpanExplanations extends TestExplanations {
27
 
 
28
 
  /* simple SpanTermQueries */
29
 
  
30
 
  public void testST1() throws Exception {
31
 
    SpanQuery q = st("w1");
32
 
    qtest(q, new int[] {0,1,2,3});
33
 
  }
34
 
  public void testST2() throws Exception {
35
 
    SpanQuery q = st("w1");
36
 
    q.setBoost(1000);
37
 
    qtest(q, new int[] {0,1,2,3});
38
 
  }
39
 
  public void testST4() throws Exception {
40
 
    SpanQuery q = st("xx");
41
 
    qtest(q, new int[] {2,3});
42
 
  }
43
 
  public void testST5() throws Exception {
44
 
    SpanQuery q = st("xx");
45
 
    q.setBoost(1000);
46
 
    qtest(q, new int[] {2,3});
47
 
  }
48
 
 
49
 
  /* some SpanFirstQueries */
50
 
  
51
 
  public void testSF1() throws Exception {
52
 
    SpanQuery q = sf(("w1"),1);
53
 
    qtest(q, new int[] {0,1,2,3});
54
 
  }
55
 
  public void testSF2() throws Exception {
56
 
    SpanQuery q = sf(("w1"),1);
57
 
    q.setBoost(1000);
58
 
    qtest(q, new int[] {0,1,2,3});
59
 
  }
60
 
  public void testSF4() throws Exception {
61
 
    SpanQuery q = sf(("xx"),2);
62
 
    qtest(q, new int[] {2});
63
 
  }
64
 
  public void testSF5() throws Exception {
65
 
    SpanQuery q = sf(("yy"),2);
66
 
    qtest(q, new int[] { });
67
 
  }
68
 
  public void testSF6() throws Exception {
69
 
    SpanQuery q = sf(("yy"),4);
70
 
    q.setBoost(1000);
71
 
    qtest(q, new int[] {2});
72
 
  }
73
 
  
74
 
  /* some SpanOrQueries */
75
 
 
76
 
  public void testSO1() throws Exception {
77
 
    SpanQuery q = sor("w1","QQ");
78
 
    qtest(q, new int[] {0,1,2,3});
79
 
  }
80
 
  public void testSO2() throws Exception {
81
 
    SpanQuery q = sor("w1","w3","zz");
82
 
    qtest(q, new int[] {0,1,2,3});
83
 
  }
84
 
  public void testSO3() throws Exception {
85
 
    SpanQuery q = sor("w5","QQ","yy");
86
 
    qtest(q, new int[] {0,2,3});
87
 
  }
88
 
  public void testSO4() throws Exception {
89
 
    SpanQuery q = sor("w5","QQ","yy");
90
 
    qtest(q, new int[] {0,2,3});
91
 
  }
92
 
 
93
 
  
94
 
  
95
 
  /* some SpanNearQueries */
96
 
  
97
 
  public void testSNear1() throws Exception {
98
 
    SpanQuery q = snear("w1","QQ",100,true);
99
 
    qtest(q, new int[] {});
100
 
  }
101
 
  public void testSNear2() throws Exception {
102
 
    SpanQuery q = snear("w1","xx",100,true);
103
 
    qtest(q, new int[] {2,3});
104
 
  }
105
 
  public void testSNear3() throws Exception {
106
 
    SpanQuery q = snear("w1","xx",0,true);
107
 
    qtest(q, new int[] {2});
108
 
  }
109
 
  public void testSNear4() throws Exception {
110
 
    SpanQuery q = snear("w1","xx",1,true);
111
 
    qtest(q, new int[] {2,3});
112
 
  }
113
 
  public void testSNear5() throws Exception {
114
 
    SpanQuery q = snear("xx","w1",0,false);
115
 
    qtest(q, new int[] {2});
116
 
  }
117
 
 
118
 
  public void testSNear6() throws Exception {
119
 
    SpanQuery q = snear("w1","w2","QQ",100,true);
120
 
    qtest(q, new int[] {});
121
 
  }
122
 
  public void testSNear7() throws Exception {
123
 
    SpanQuery q = snear("w1","xx","w2",100,true);
124
 
    qtest(q, new int[] {2,3});
125
 
  }
126
 
  public void testSNear8() throws Exception {
127
 
    SpanQuery q = snear("w1","xx","w2",0,true);
128
 
    qtest(q, new int[] {2});
129
 
  }
130
 
  public void testSNear9() throws Exception {
131
 
    SpanQuery q = snear("w1","xx","w2",1,true);
132
 
    qtest(q, new int[] {2,3});
133
 
  }
134
 
  public void testSNear10() throws Exception {
135
 
    SpanQuery q = snear("xx","w1","w2",0,false);
136
 
    qtest(q, new int[] {2});
137
 
  }
138
 
  public void testSNear11() throws Exception {
139
 
    SpanQuery q = snear("w1","w2","w3",1,true);
140
 
    qtest(q, new int[] {0,1});
141
 
  }
142
 
 
143
 
  
144
 
  /* some SpanNotQueries */
145
 
 
146
 
  public void testSNot1() throws Exception {
147
 
    SpanQuery q = snot(sf("w1",10),st("QQ"));
148
 
    qtest(q, new int[] {0,1,2,3});
149
 
  }
150
 
  public void testSNot2() throws Exception {
151
 
    SpanQuery q = snot(sf("w1",10),st("QQ"));
152
 
    q.setBoost(1000);
153
 
    qtest(q, new int[] {0,1,2,3});
154
 
  }
155
 
  public void testSNot4() throws Exception {
156
 
    SpanQuery q = snot(sf("w1",10),st("xx"));
157
 
    qtest(q, new int[] {0,1,2,3});
158
 
  }
159
 
  public void testSNot5() throws Exception {
160
 
    SpanQuery q = snot(sf("w1",10),st("xx"));
161
 
    q.setBoost(1000);
162
 
    qtest(q, new int[] {0,1,2,3});
163
 
  }
164
 
  public void testSNot7() throws Exception {
165
 
    SpanQuery f = snear("w1","w3",10,true);
166
 
    f.setBoost(1000);
167
 
    SpanQuery q = snot(f, st("xx"));
168
 
    qtest(q, new int[] {0,1,3});
169
 
  }
170
 
  public void testSNot10() throws Exception {
171
 
    SpanQuery t = st("xx");
172
 
    t.setBoost(10000);
173
 
    SpanQuery q = snot(snear("w1","w3",10,true), t);
174
 
    qtest(q, new int[] {0,1,3});
175
 
  }
176
 
 
177
 
}