Skip to content

Commit 27996a5

Browse files
committed
down to two test failures, but I think these were failing pre-upgrade too
1 parent 2997425 commit 27996a5

13 files changed

+50
-41
lines changed

TODO

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
get unused import detection, tidy, checkstyle running
22

3+
fix test runner
4+
- rewrite the "Reproduce with" to build.py
5+
- remove all the useless stack frames from a test failure -- don't need to see that boilerplate, just the relevant frames (my sources)
6+
37
expose HNSW/KNN!
48

59
finish getting distributed queue approach online

build.py

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
('org.apache.lucene', 'lucene-queries', LUCENE_VERSION),
3737
('org.apache.lucene', 'lucene-queryparser', LUCENE_VERSION),
3838
('org.apache.lucene', 'lucene-suggest', LUCENE_VERSION),
39+
('org.apache.lucene', 'lucene-memory', LUCENE_VERSION),
3940
('org.apache.lucene', 'lucene-expressions', LUCENE_VERSION),
4041
('org.antlr', 'antlr4-runtime', '4.11.1'),
4142
('org.ow2.asm', 'asm', '5.1'),

src/java/org/apache/lucene/server/handlers/CreateIndexHandler.java

-2
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ public String finish() throws Exception {
7575
throw r.bad("invalid indexName \"" + indexName + "\": " + iae.toString(), iae);
7676
}
7777
// Create the first shard
78-
System.out.println("NOW ADD SHARD 0");
7978
indexState.addShard(0, true);
80-
System.out.println("DONE ADD SHARD 0");
8179
return "{}";
8280
}
8381
};

src/java/org/apache/lucene/server/handlers/SearchHandler.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,9 @@ public Map<String,Object[]> highlightToObjects(String fieldsIn[], Query query, i
595595
@Override
596596
protected List<CharSequence[]> loadFieldValues(String[] fields, DocIdSetIterator docIDs, int maxLength) throws IOException {
597597

598+
// nocommit why was this needed? did 3rd parameter here change meaning?
599+
maxLength = getMaxLength();
600+
598601
List<CharSequence[]> allValues = new ArrayList<>();
599602
while (true) {
600603
int docID = docIDs.nextDoc();
@@ -2020,7 +2023,7 @@ static void fillFacetResults(Request r, SearcherAndTaxonomy s, FacetsCollector d
20202023
Facets facets = new LongRangeFacetCounts(fd.name,
20212024
c,
20222025
ranges);
2023-
facetResult = facets.getTopChildren(0, fd.name);
2026+
facetResult = facets.getTopChildren(Integer.MAX_VALUE, fd.name);
20242027
} else if (fd.valueType == FieldDef.FieldValueType.FLOAT || fd.valueType == FieldDef.FieldValueType.DOUBLE || fd.valueType == FieldDef.FieldValueType.VIRTUAL) {
20252028
List<Object> rangeList = r2.getList("numericRanges");
20262029
DoubleRange[] ranges = new DoubleRange[rangeList.size()];
@@ -2288,7 +2291,7 @@ public FinishRequest handle(final IndexState indexState, final Request r, Map<St
22882291
field = f.getString("field");
22892292
if (f.hasParam("highlight")) {
22902293
highlight = f.getEnum("highlight");
2291-
if (!highlight.equals("no")) {
2294+
if (highlight.equals("no") == false) {
22922295
perField = new FieldHighlightConfig();
22932296
highlightFields.put(field, perField);
22942297
perField.mode = highlight;
@@ -2803,7 +2806,7 @@ protected boolean scoreSubDocsAtOnce() {
28032806
}
28042807

28052808
// still just an int
2806-
o3.put("totalHits", group.totalHits);
2809+
o3.put("totalHits", group.totalHits.value);
28072810

28082811
if (Float.isNaN(group.maxScore) == false) {
28092812
o3.put("maxScore", group.maxScore);

src/test/org/apache/lucene/server/TestAddDocuments.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ public void testAddDocuments() throws Exception {
8080

8181
// search on parent:
8282
result = send("search", String.format(Locale.ROOT, "{queryText: 'name:Lisa', searcher: {indexGen: %d}}", indexGen));
83-
assertEquals(1, result.get("totalHits.value"));
83+
assertEquals(1, getInt(result, "totalHits.value"));
8484

8585
// search on child:
8686
result = send("search", String.format(Locale.ROOT, "{queryText: 'skill:python', searcher: {indexGen: %d}}", indexGen));
87-
assertEquals(1, result.get("totalHits.value"));
87+
assertEquals(1, getInt(result, "totalHits.value"));
8888
}
8989

9090
public void testBulkAddDocuments() throws Exception {
@@ -113,11 +113,11 @@ public void testBulkAddDocuments() throws Exception {
113113

114114
// search on parent:
115115
result = send("search", String.format(Locale.ROOT, "{queryText: 'name:Lisa', searcher: {indexGen: %d}}", indexGen));
116-
assertEquals(100, result.get("totalHits.value"));
116+
assertEquals(100, getInt(result, "totalHits.value"));
117117

118118
// search on child:
119119
result = send("search", String.format(Locale.ROOT, "{queryText: 'skill:python', searcher: {indexGen: %d}}", indexGen));
120-
assertEquals(100, result.get("totalHits.value"));
120+
assertEquals(100, getInt(result, "totalHits.value"));
121121
}
122122

123123
// TODO: test block join/grouping once they are impl'd!

src/test/org/apache/lucene/server/TestBooleanFieldType.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void testStored() throws Exception {
5757
send("addDocument", "{fields: {id: 0, flagStored: false}}");
5858
long gen = getLong(send("addDocument", "{fields: {id: 1, flagStored: true}}"), "indexGen");
5959
JSONObject o = send("search", "{searcher: {indexGen: " + gen + "}, query: MatchAllDocsQuery, retrieveFields: [id, flagStored]}");
60-
assertEquals(2, getInt(o, "totalHits"));
60+
assertEquals(2, getInt(o, "totalHits.value"));
6161
assertFalse(getBoolean(o, "hits[0].fields.flagStored"));
6262
assertTrue(getBoolean(o, "hits[1].fields.flagStored"));
6363
}
@@ -67,7 +67,7 @@ public void testIndexed() throws Exception {
6767
send("addDocument", "{fields: {id: 0, flagIndexed: false, flagStored: false}}");
6868
long gen = getLong(send("addDocument", "{fields: {id: 1, flagIndexed: true, flagStored: true}}"), "indexGen");
6969
JSONObject o = send("search", "{searcher: {indexGen: " + gen + "}, query: {class: BooleanFieldQuery, field: flagIndexed}, retrieveFields: [id, flagStored]}");
70-
assertEquals(1, getInt(o, "totalHits"));
70+
assertEquals(1, getInt(o, "totalHits.value"));
7171
assertTrue(getBoolean(o, "hits[0].fields.flagStored"));
7272
}
7373

src/test/org/apache/lucene/server/TestFacets.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private JSONObject search(String query, long indexGen, String sortField, boolean
123123
if (sortField != null) {
124124
JSONObject sort = new JSONObject();
125125
o.put("sort", sort);
126-
sort.put("doDocScores", true);
126+
// sort.put("doDocScores", true);
127127

128128
JSONArray sortFields = new JSONArray();
129129
sort.put("fields", sortFields);

src/test/org/apache/lucene/server/TestGrouping.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void testGrouping() throws Exception {
8181
long gen = addDocument(0, "Bob", "this is a test.", 10.99f, "2012/10/17");
8282

8383
JSONObject o2 = search("test", gen, null, false, false, "author", null);
84-
assertEquals(4, ((Number) o2.get("totalHits.value")).intValue());
84+
assertEquals(4, getInt(o2, "totalHits.value"));
8585
assertEquals(4, ((Number) o2.get("totalGroupedHits")).intValue());
8686
JSONArray a = (JSONArray) o2.get("groups");
8787
assertEquals(3, a.size());
@@ -236,7 +236,7 @@ public void testGroupingWithGroupSort() throws Exception {
236236
long gen = addDocument(0, "Bob", "this is a test.", 7.99f, "2013/10/17");
237237

238238
JSONObject o2 = search("test", gen, "price", false, false, "author", "price");
239-
assertEquals(4, ((Number) o2.get("totalHits")).intValue());
239+
assertEquals(4, getInt(o2, "totalHits.value"));
240240
assertEquals(4, ((Number) o2.get("totalGroupedHits")).intValue());
241241
JSONArray a = (JSONArray) o2.get("groups");
242242
assertEquals(3, a.size());

src/test/org/apache/lucene/server/TestHighlight.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public void testMultiValuedWholeHighlight() throws Exception {
156156

157157
long gen = addDocument("{fields: {authors: ['Dr. Seuss', 'Bob Smith', 'Seuss is Fun. Some extra content.']}}");
158158
JSONObject result = send("search", "{queryText: 'authors:seuss', retrieveFields: [{field: authors, highlight: whole}], searcher: {indexGen: " + gen + "}}");
159-
assertEquals(1, getInt(result, "totalHits"));
159+
assertEquals(1, getInt(result, "totalHits.value"));
160160
JSONArray fields = getArray(result, "hits[0].fields.authors");
161161
assertEquals(3, fields.size());
162162
assertEquals("Dr. <b>Seuss</b>", renderSingleHighlight((JSONArray) fields.get(0)));
@@ -169,7 +169,7 @@ public void testMultiValuedSnippetHighlight() throws Exception {
169169

170170
long gen = addDocument("{fields: {authors: ['Dr. Seuss', 'Bob Smith', 'Seuss is Fun. Some extra content.']}}");
171171
JSONObject result = send("search", "{queryText: 'authors:seuss', retrieveFields: [{field: authors, highlight: snippets, maxPassages: 1}], searcher: {indexGen: " + gen + "}}");
172-
assertEquals(1, getInt(result, "totalHits"));
172+
assertEquals(1, getInt(result, "totalHits.value"));
173173
assertEquals(1, getInt(result, "hits[0].fields.authors.length"));
174174
assertEquals("<b>Seuss</b> Bob Smith <b>Seuss</b> is Fun. ", renderSingleHighlight(getArray(result, "hits[0].fields.authors[0].parts")));
175175
}
@@ -179,7 +179,7 @@ public void testPerFieldMaxPassages() throws Exception {
179179
deleteAllDocs();
180180
long gen = addDocument("{fields: {body: 'This sentence has test. This one does not. Here is test again.', authors: ['This sentence has test. This one does not. Here is test again.']}}");
181181
JSONObject result = send("search", "{queryText: 'test', retrieveFields: [{field: authors, highlight: snippets, maxPassages: 1}, {field: body, highlight: snippets, maxPassages: 2}], searcher: {indexGen: " + gen + "}}");
182-
assertEquals(1, getInt(result, "totalHits"));
182+
assertEquals(1, getInt(result, "totalHits.value"));
183183

184184
// Author has just 1 passage:
185185
assertEquals(1, getInt(result, "hits[0].fields.authors.length"));

src/test/org/apache/lucene/server/TestIndexing.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public void testBulkAddDocument() throws Exception {
204204
assertEquals(100, result.get("indexedDocumentCount"));
205205
long indexGen = getLong(result, "indexGen");
206206
JSONObject r = search("99", indexGen, null, false, true, null, null);
207-
assertEquals(1, ((Integer) r.get("totalHits.value")).intValue());
207+
assertEquals(1, getInt(r, "totalHits.value"));
208208
}
209209

210210
public void testBulkAddDocument2() throws Exception {
@@ -248,6 +248,8 @@ public void testAddAfterStop() throws Exception {
248248
send("startIndex");
249249
}
250250

251+
// nocommit bye bye index time boosting! was there a replacement? search time only?
252+
/*
251253
public void testBoost() throws Exception {
252254
createIndex("boost");
253255
// Just to test merge rate limiting:
@@ -276,6 +278,7 @@ public void testBoost() throws Exception {
276278
277279
send("deleteIndex");
278280
}
281+
*/
279282

280283
public void testInvalidNormsFormat() throws Exception {
281284
try {

src/test/org/apache/lucene/server/TestServer.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private JSONObject search(String query, long indexGen, String sortField, boolean
9999
if (sortField != null) {
100100
JSONObject sort = new JSONObject();
101101
o.put("sort", sort);
102-
sort.put("doDocScores", true);
102+
// sort.put("doDocScores", true);
103103

104104
JSONArray sortFields = new JSONArray();
105105
sort.put("fields", sortFields);
@@ -150,7 +150,7 @@ public void testNumericSort() throws Exception {
150150
addDocument(0, "Lisa", "this is a test", 10.99f, "2012/10/1");
151151
long gen = addDocument(1, "Tom", "this is also a test", 14.99f, "2012/11/3");
152152
JSONObject o = search("test", gen, "price", false, true, null, null);
153-
assertEquals(2, ((Number) o.get("totalHits.value")).intValue());
153+
assertEquals(2, getInt(o, "totalHits.value"));
154154
JSONArray hits = (JSONArray) o.get("hits");
155155
assertEquals(2, hits.size());
156156

@@ -166,7 +166,7 @@ public void testReverseNumericSort() throws Exception {
166166
addDocument(0, "Frank", "this is a test", 10.99f, "2012/10/1");
167167
long gen = addDocument(1, "Lisa", "this is also a test", 14.99f, "2012/11/3");
168168
JSONObject o = search("test", gen, "price", true, true, null, null);
169-
assertEquals(2, ((Number) o.get("totalHits.value")).intValue());
169+
assertEquals(2, getInt(o, "totalHits.value"));
170170

171171
JSONArray hits = (JSONArray) o.get("hits");
172172
assertEquals(2, hits.size());
@@ -183,13 +183,13 @@ public void testPrevSearchState() throws Exception {
183183
long gen = addDocument(0, "Tom", "this is a test. here is a random sentence. here is another sentence with test in it.", 10.99f, "2012/10/17");
184184

185185
JSONObject o = search("test", gen, null, false, false, null, null);
186-
assertEquals(1, ((Number) o.get("totalHits.value")).intValue());
186+
assertEquals(1, getInt(o, "totalHits.value"));
187187

188188
// Add another document
189189
gen = addDocument(0, "Melanie", "this is a test. here is a random sentence. here is another sentence with test in it.", 10.99f, "2012/10/17");
190190

191191
JSONObject o2 = search("test", gen, null, false, false, null, null);
192-
assertEquals(2, ((Number) o2.get("totalHits.value")).intValue());
192+
assertEquals(2, getInt(o2, "totalHits.value"));
193193

194194
// Now the first search does a follow-on search, so we
195195
// should only see 1 document since it should be using
@@ -201,7 +201,7 @@ public void testPrevSearchState() throws Exception {
201201
//System.out.println("send: " + o3);
202202
JSONObject o4 = send("search", o3);
203203

204-
assertEquals(1, ((Number) o4.get("totalHits.value")).intValue());
204+
assertEquals(1, getInt(o4, "totalHits.value"));
205205
}
206206

207207
public void testInvalidFields() throws Exception {
@@ -362,7 +362,7 @@ public void testServerRestart() throws Exception {
362362
bounceServer();
363363
send("startIndex");
364364
JSONObject o = search("test", 0, null, false, true, null, null);
365-
assertEquals(1, ((Number) o.get("totalHits.value")).intValue());
365+
assertEquals(1, getInt(o, "totalHits.value"));
366366
}
367367

368368
public void testStatsHandler() throws Exception {

src/test/org/apache/lucene/server/TestSnapshots.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void testBasic() throws Exception {
5757
commit();
5858

5959
o = send("search", "{queryText: 'body:body', searcher: {indexGen:" + indexGen + "}}");
60-
assertEquals(1, o.get("totalHits"));
60+
assertEquals(1, getInt(o, "totalHits.value"));
6161

6262
// Take snapshot before making some changes:
6363
JSONObject result = send("createSnapshot");
@@ -102,27 +102,27 @@ public void testBasic() throws Exception {
102102

103103
// Make sure we can search the snapshot and only get 1 hit:
104104
send("search", "{retrieveFields: [id], searcher: {snapshot: \"" + snapshotID + "\"}, query: MatchAllDocsQuery}");
105-
assertEquals(1, getInt("totalHits"));
105+
assertEquals(1, getInt("totalHits.value"));
106106
assertEquals("0", getString("hits[0].fields.id"));
107107

108108
// Make sure we can search the current searcher and we
109109
// get 2 hits:
110110
send("search", "{retrieveFields: [id], searcher: {indexGen: " + indexGen2 + "}, query: MatchAllDocsQuery}");
111-
assertEquals(2, getInt("totalHits"));
111+
assertEquals(2, getInt("totalHits.value"));
112112

113113
// Bounce the server:
114114
bounceServer();
115115
send("startIndex");
116116

117117
// Make sure we can search the snapshot and still only get 1 hit:
118118
send("search", "{retrieveFields: [id], searcher: {snapshot: \"" + snapshotID + "\"}, query: MatchAllDocsQuery}");
119-
assertEquals(1, getInt("totalHits"));
119+
assertEquals(1, getInt("totalHits.value"));
120120
assertEquals("0", getString("hits[0].fields.id"));
121121

122122
// Make sure we can search the current searcher and we
123123
// get 2 hits:
124124
send("search", "{retrieveFields: [id], query: MatchAllDocsQuery}");
125-
assertEquals(2, getInt("totalHits"));
125+
assertEquals(2, getInt("totalHits.value"));
126126

127127
// Make sure files still exist (snapshot persisted):
128128
for(Map.Entry<String,Object> ent : result.entrySet()) {
@@ -147,7 +147,7 @@ public void testBasic() throws Exception {
147147

148148
// Make sure we can still search the snapshot:
149149
send("search", "{retrieveFields: [id], searcher: {snapshot: \"" + snapshotID + "\"}, query: MatchAllDocsQuery}");
150-
assertEquals(1, getInt("totalHits"));
150+
assertEquals(1, getInt("totalHits.value"));
151151
assertEquals("0", getString("hits[0].fields.id"));
152152

153153
// Now, release the snapshot:
@@ -175,7 +175,7 @@ public void testBasic() throws Exception {
175175

176176
// Make sure search is working, and both docs are visible:
177177
o = send("search", "{queryText: 'body:body'}");
178-
assertEquals(2, o.get("totalHits"));
178+
assertEquals(2, getInt(o, "totalHits.value"));
179179

180180
} finally {
181181
rmDir(backupDir);

src/test/org/apache/lucene/server/TestVirtualFields.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ public void testWithScore2() throws Exception {
153153
assertEquals(0, getInt("hits[1].fields.id"));
154154

155155
// nocommit don't test actual scores
156-
assertEquals(0.861380339f, getFloat("hits[0].fields.scoreboost"), .0001f);
157-
assertEquals(0.16823316f, getFloat("hits[1].fields.scoreboost"), .0001f);
156+
assertEquals(0.77806407, getFloat("hits[0].fields.scoreboost"), .0001f);
157+
assertEquals(0.08092601F, getFloat("hits[1].fields.scoreboost"), .0001f);
158158

159159
assertEquals(.6931f, getFloat("hits[0].fields.logboost"), .0001f);
160160
assertEquals(0.0f, getFloat("hits[1].fields.logboost"), .0001f);
@@ -171,10 +171,10 @@ public void testWithScore3() throws Exception {
171171
assertEquals(1, getInt("hits[0].fields.id"));
172172
assertEquals(0, getInt("hits[1].fields.id"));
173173

174-
assertEquals(0.861380339f, getFloat("hits[0].fields.scoreboost"), .0001f);
175-
assertEquals(0.16823316f, getFloat("hits[1].fields.scoreboost"), .0001f);
174+
assertEquals(0.7780640F, getFloat("hits[0].fields.scoreboost"), .0001f);
175+
assertEquals(0.0809260F, getFloat("hits[1].fields.scoreboost"), .0001f);
176176

177-
assertEquals(.6931f, getFloat("hits[0].fields.logboost"), .0001f);
177+
assertEquals(0.6931471F, getFloat("hits[0].fields.logboost"), .0001f);
178178
assertEquals(0.0f, getFloat("hits[1].fields.logboost"), .0001f);
179179
}
180180

@@ -251,8 +251,8 @@ public void testRetrievedDynamicField() throws Exception {
251251
assertEquals(1, getInt("hits[0].fields.id"));
252252
assertEquals(0, getInt("hits[1].fields.id"));
253253

254-
assertEquals(2.584141017f, getFloat("hits[0].fields.scoreboost3"), .0001f);
255-
assertEquals(0.5046995f, getFloat("hits[1].fields.scoreboost3"), .0001f);
254+
assertEquals(2.334192, getFloat("hits[0].fields.scoreboost3"), .0001f);
255+
assertEquals(0.24277804, getFloat("hits[1].fields.scoreboost3"), .0001f);
256256
}
257257

258258
public void testSortedDynamicField() throws Exception {
@@ -265,7 +265,7 @@ public void testSortedDynamicField() throws Exception {
265265
assertEquals(0, getInt("hits[0].fields.id"));
266266
assertEquals(1, getInt("hits[1].fields.id"));
267267

268-
assertEquals(0.50469947f, getFloat("hits[0].fields.sortFields.scoreboost3"), .0001f);
269-
assertEquals(2.5841410f, getFloat("hits[1].fields.sortFields.scoreboost3"), .0001f);
268+
assertEquals(0.24277800F, getFloat("hits[0].fields.sortFields.scoreboost3"), .0001f);
269+
assertEquals(2.3341922F, getFloat("hits[1].fields.sortFields.scoreboost3"), .0001f);
270270
}
271271
}

0 commit comments

Comments
 (0)