Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLR-17631: Upgrade main to Lucene 10.x #3053

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c22cfaa
WIP: Upgrading to Lucene 10
Jan 13, 2025
822d562
Removed dependency on TimeLimitingCollector
noblepaul Jan 14, 2025
c29bdeb
Removed the deprecated methods
noblepaul Jan 15, 2025
8c9e9ed
Removed dependency on deprecated TopDocCollector
noblepaul Jan 15, 2025
f4b8b16
Moved setRewriteMethod() to constructor, replaced scorer() with score…
Jan 15, 2025
38a22d4
Replaced some more scorer() with scorerSupplier()
Jan 15, 2025
d4770a5
Changed rewrite method signature, added DV skip to FieldInfo construc…
Jan 15, 2025
705fe9b
Changed rewrite method signature, added DV skip to FieldInfo construc…
Jan 15, 2025
8b24db8
More fixes
Jan 15, 2025
7ec4b98
Removing deprecated method getTermVectors(int docID)
Jan 15, 2025
5dcff09
Removed TopScoreDocsCollector.create() and replaced with manager's ne…
Jan 15, 2025
d94b22f
Deal with removal of TopFieldCollector.create()
Jan 15, 2025
5c9dbf0
Removed dependencies on deprecated TimeLimitingCollector
noblepaul Jan 16, 2025
9bb7397
removed deprecated methods
noblepaul Jan 16, 2025
7f2a77b
Fixed deprecated methods
noblepaul Jan 16, 2025
6224d6a
Fixed syntax errors
noblepaul Jan 16, 2025
18ec6ea
Fixed syntax errors
noblepaul Jan 16, 2025
4c141a6
Test compilation fixes
Jan 17, 2025
f490667
Adding our own scorer supplier
Jan 17, 2025
f5df6c7
bulk scorer modified
noblepaul Jan 17, 2025
e1fe99f
bulk scorer modified
noblepaul Jan 18, 2025
bcd4815
Don't close a stream during request parsing
Jan 18, 2025
dfead62
Fixing scorer issues with range queries, thereby passing ConvertedLeg…
Jan 21, 2025
a6ede24
Fixing SortedSetDocValues.NO_MORE_ORDS removal issue, fixed SolrIndex…
Jan 22, 2025
20eb534
More improper ordinals handling
Jan 22, 2025
266dae8
More ords handling fixed, passing TestJsonFacets now
Jan 23, 2025
c723c4d
Use match all docs for null filter
noblepaul Jan 23, 2025
f98f703
remove or tweak ScoreAndDoc use
cpoerschke Jan 24, 2025
494b6b4
make solr/modules/ltr/src/java compile
cpoerschke Jan 29, 2025
f9c3af4
make solr/modules/*/src/java compile (mostly)
cpoerschke Jan 31, 2025
fe548f7
make solr/modules/ltr/src/test compile
cpoerschke Jan 31, 2025
5fdc900
Merge remote-tracking branch 'origin/main' into ishan/upgrade-to-luce…
cpoerschke Feb 3, 2025
96abdce
./gradlew resolveAndLockAll --write-locks
cpoerschke Feb 3, 2025
c246d7f
better merge conflict resolution for TestCodecSupport.java
cpoerschke Feb 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ description = 'Grandparent project for Apache Solr'
// Propagate version and derived properties across projects.
allprojects {
version = rootProject.version

gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "1000"
}
}
}

ext {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ apache-httpcomponents-httpcore = "4.4.16"
apache-httpcomponents-httpmime = "4.5.14"
apache-kafka = "3.7.1"
apache-log4j = "2.21.0"
apache-lucene = "9.12.1"
apache-lucene = "10.1.0"
apache-opennlp = "1.9.4"
apache-poi = "5.2.2"
apache-rat = "0.15"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.file.Path;

import org.apache.lucene.store.Directory;
import org.apache.lucene.store.LockFactory;
import org.apache.lucene.store.MMapDirectory;
Expand All @@ -34,8 +35,6 @@
* <p>Can set the following parameters:
*
* <ul>
* <li>unmap -- See {@link MMapDirectory#setUseUnmap(boolean)}
* <li>preload -- See {@link MMapDirectory#setPreload(boolean)}
* <li>maxChunkSize -- The Max chunk size. See {@link MMapDirectory#MMapDirectory(Path,
* LockFactory, long)}
* </ul>
Expand Down Expand Up @@ -66,7 +65,7 @@ public void init(NamedList<?> args) {
protected Directory create(String path, LockFactory lockFactory, DirContext dirContext)
throws IOException {
MMapDirectory mapDirectory = new MMapDirectory(Path.of(path), lockFactory, maxChunk);
mapDirectory.setPreload(preload);
mapDirectory.setPreload((s, ioContext) -> preload);
return mapDirectory;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import org.apache.lucene.codecs.KnnVectorsReader;
import org.apache.lucene.codecs.KnnVectorsWriter;
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.lucene912.Lucene912Codec;
import org.apache.lucene.codecs.lucene912.Lucene912Codec.Mode;
import org.apache.lucene.codecs.lucene101.Lucene101Codec;
import org.apache.lucene.codecs.lucene101.Lucene101Codec.Mode;
import org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsFormat;
import org.apache.lucene.index.SegmentReadState;
import org.apache.lucene.index.SegmentWriteState;
Expand Down Expand Up @@ -97,7 +97,7 @@ public void init(NamedList<?> args) {
log.debug("Using default compressionMode: {}", compressionMode);
}
codec =
new Lucene912Codec(compressionMode) {
new Lucene101Codec(compressionMode) {
@Override
public PostingsFormat getPostingsFormatForField(String field) {
final SchemaField schemaField = core.getLatestSchema().getFieldOrNull(field);
Expand Down
4 changes: 2 additions & 2 deletions solr/core/src/java/org/apache/solr/core/SolrConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,12 @@ private SolrConfig(SolrResourceLoader loader, String name, Properties substituta
indexConfig = new SolrIndexConfig(get("indexConfig"), null);

booleanQueryMaxClauseCount =
get("query").get("maxBooleanClauses").intVal(BooleanQuery.getMaxClauseCount());
get("query").get("maxBooleanClauses").intVal(IndexSearcher.getMaxClauseCount());
if (IndexSearcher.getMaxClauseCount() < booleanQueryMaxClauseCount) {
log.warn(
"solrconfig.xml: <maxBooleanClauses> of {} is greater than global limit of {} and will have no effect {}",
booleanQueryMaxClauseCount,
BooleanQuery.getMaxClauseCount(),
IndexSearcher.getMaxClauseCount(),
"set 'maxBooleanClauses' in solr.xml to increase global limit");
}
prefixQueryMinPrefixLength =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ default void copyIndexFileFrom(
Directory sourceDir, String sourceFileName, Directory destDir, String destFileName)
throws IOException {
boolean success = false;
try (ChecksumIndexInput is = sourceDir.openChecksumInput(sourceFileName, IOContext.READONCE);
try (ChecksumIndexInput is = sourceDir.openChecksumInput(sourceFileName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IndexOutput os = destDir.createOutput(destFileName, IOContext.READONCE)) {
os.copyBytes(is, is.length() - CodecUtil.footerLength());

Expand Down Expand Up @@ -247,7 +247,7 @@ default void delete(URI path, Collection<String> files) throws IOException {
* @since 8.3.0
*/
default Checksum checksum(Directory dir, String fileName) throws IOException {
try (IndexInput in = dir.openChecksumInput(fileName, IOContext.READONCE)) {
try (IndexInput in = dir.openChecksumInput(fileName)) {
return new Checksum(CodecUtil.retrieveChecksum(in), in.length());
}
}
Expand Down
4 changes: 2 additions & 2 deletions solr/core/src/java/org/apache/solr/handler/BlobHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void handleRequestBody(final SolrQueryRequest req, SolrQueryResponse rsp)
new Sort(new SortField("version", SortField.Type.LONG, true)));

long version = 0;
if (docs.totalHits.value > 0) {
if (docs.totalHits.value() > 0) {
Document doc = req.getSearcher().getDocFetcher().doc(docs.scoreDocs[0].doc);
Number n = doc.getField("version").numericValue();
version = n.longValue();
Expand Down Expand Up @@ -210,7 +210,7 @@ public void handleRequestBody(final SolrQueryRequest req, SolrQueryResponse rsp)
qparser.parse(),
1,
new Sort(new SortField("version", SortField.Type.LONG, true)));
if (docs.totalHits.value > 0) {
if (docs.totalHits.value() > 0) {
rsp.add(
ReplicationAPIBase.FILE_STREAM,
new SolrCore.RawWriter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private BooleanQuery getBoostedQuery(Query mltquery) {
BooleanQuery.Builder newQ = new BooleanQuery.Builder();
newQ.setMinimumNumberShouldMatch(boostedQuery.getMinimumNumberShouldMatch());
for (BooleanClause clause : boostedQuery) {
Query q = clause.getQuery();
Query q = clause.query();
float originalBoost = 1f;
if (q instanceof BoostQuery bq) {
q = bq.getQuery();
Expand All @@ -390,8 +390,8 @@ private BooleanQuery getBoostedQuery(Query mltquery) {
q =
((fieldBoost != null)
? new BoostQuery(q, fieldBoost * originalBoost)
: clause.getQuery());
newQ.add(q, clause.getOccur());
: clause.query());
newQ.add(q, clause.occur());
}
boostedQuery = newQ.build();
}
Expand Down Expand Up @@ -478,7 +478,7 @@ public List<InterestingTerm> getInterestingTerms(BooleanQuery boostedMLTQuery, i
if (maxTerms > -1 && output.size() >= maxTerms) {
break;
}
Query q = o.getQuery();
Query q = o.query();
float boost = 1f;
if (q instanceof BoostQuery bq) {
q = bq.getQuery();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ private GetSegmentDataResponse.SingleSegmentData getSegmentInfo(
if (seg != null) {
LeafMetaData metaData = seg.getMetaData();
if (metaData != null) {
segmentInfo.createdVersionMajor = metaData.getCreatedVersionMajor();
segmentInfo.minVersion = metaData.getMinVersion().toString();
if (metaData.getSort() != null) {
segmentInfo.sort = metaData.getSort().toString();
segmentInfo.createdVersionMajor = metaData.createdVersionMajor();
segmentInfo.minVersion = metaData.minVersion().toString();
if (metaData.sort() != null) {
segmentInfo.sort = metaData.sort().toString();
}
}
}
Expand Down Expand Up @@ -417,7 +417,7 @@ private GetSegmentDataResponse.SegmentSingleFieldInfo getFieldInfo(
} else {
flags.append("----");
}
flags.append((fi.hasVectors()) ? FieldFlag.TERM_VECTOR_STORED.getAbbreviation() : '-');
flags.append((fi.hasTermVectors()) ? FieldFlag.TERM_VECTOR_STORED.getAbbreviation() : '-');
flags.append((fi.omitsNorms()) ? FieldFlag.OMIT_NORMS.getAbbreviation() : '-');

flags.append((DOCS == opts) ? FieldFlag.OMIT_TF.getAbbreviation() : '-');
Expand Down Expand Up @@ -477,9 +477,9 @@ private GetSegmentDataResponse.SegmentSingleFieldInfo getFieldInfo(
if (!hasPoints && (sf.omitNorms() != fi.omitsNorms())) {
nonCompliant.put("omitNorms", "schema=" + sf.omitNorms() + ", segment=" + fi.omitsNorms());
}
if (sf.storeTermVector() != fi.hasVectors()) {
if (sf.storeTermVector() != fi.hasTermVectors()) {
nonCompliant.put(
"termVectors", "schema=" + sf.storeTermVector() + ", segment=" + fi.hasVectors());
"termVectors", "schema=" + sf.storeTermVector() + ", segment=" + fi.hasTermVectors());
}
if (sf.storeOffsetsWithPositions()
!= (fi.getIndexOptions() == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,7 @@
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.OrdinalMap;
import org.apache.lucene.index.SortedDocValues;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Collector;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.LeafCollector;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Scorable;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.ScoreMode;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.TermInSetQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.TopDocsCollector;
import org.apache.lucene.search.TopFieldCollector;
import org.apache.lucene.search.TopScoreDocCollector;
import org.apache.lucene.search.TotalHitCountCollector;
import org.apache.lucene.search.TotalHits;
import org.apache.lucene.search.*;
import org.apache.lucene.util.BitSetIterator;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefBuilder;
Expand Down Expand Up @@ -778,13 +761,13 @@ private DocSlice collectorToDocSlice(
docs[i] = scoreDoc.doc;
scores[i] = scoreDoc.score;
}
assert topDocs.totalHits.relation == TotalHits.Relation.EQUAL_TO;
assert topDocs.totalHits.relation() == TotalHits.Relation.EQUAL_TO;
return new DocSlice(
0,
docs.length,
docs,
scores,
topDocs.totalHits.value,
topDocs.totalHits.value(),
Float.NaN,
TotalHits.Relation.EQUAL_TO);
}
Expand Down Expand Up @@ -825,9 +808,9 @@ protected final Collector getCollector() throws IOException {
if (limit == 0) {
collector = new TotalHitCountCollector();
} else if (sort == null) {
collector = TopScoreDocCollector.create(limit, Integer.MAX_VALUE);
collector = new TopScoreDocCollectorManager(limit, Integer.MAX_VALUE).newCollector();
} else {
collector = TopFieldCollector.create(sort, limit, Integer.MAX_VALUE);
collector = new TopFieldCollectorManager(sort, limit, Integer.MAX_VALUE).newCollector();
}
return collector;
}
Expand All @@ -847,7 +830,7 @@ private Query getGroupQuery(String fname, FieldType ft, int size, LongHashSet gr
bytesRefs[++index] = term.toBytesRef();
}

return new TermInSetQuery(fname, bytesRefs);
return new TermInSetQuery(fname, Arrays.asList(bytesRefs));
}

private Query getPointGroupQuery(SchemaField sf, int size, LongHashSet groupSet) {
Expand Down Expand Up @@ -889,7 +872,7 @@ private Query getGroupQuery(String fname, int size, IntObjectHashMap<BytesRef> o
IntObjectCursor<BytesRef> cursor = it.next();
bytesRefs[++index] = cursor.value;
}
return new TermInSetQuery(fname, bytesRefs);
return new TermInSetQuery(fname, Arrays.asList(bytesRefs));
}

////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1755,7 +1755,6 @@ protected static class ScoreAndDoc extends Scorable {
this.score = score;
}

@Override
public int docID() {
return docid;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this can be removed, haven't tried it yet though.

Suggested change
public int docID() {
return docid;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ private void addDebugInfo(ResponseBuilder rb, Elevation elevation) {
// Extract the elevated terms into a list
match = new ArrayList<>(elevation.includeQuery.clauses().size());
for (BooleanClause clause : elevation.includeQuery.clauses()) {
TermQuery tq = (TermQuery) clause.getQuery();
TermQuery tq = (TermQuery) clause.query();
match.add(tq.getTerm().text());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public void process(ResponseBuilder rb) throws IOException {
if (rb.getFilters() != null) {
for (Query raw : rb.getFilters()) {
raw = makeQueryable(raw);
Query q = raw.rewrite(searcherInfo.getSearcher().getIndexReader());
Query q = raw.rewrite(searcherInfo.getSearcher());
Scorer scorer =
searcherInfo
.getSearcher()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.lucene.index.CompositeReader;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.DocValuesSkipper;
import org.apache.lucene.index.DocValuesType;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.FieldInfos;
Expand Down Expand Up @@ -101,7 +102,7 @@ public static LeafReader wrap(IndexReader reader) throws IOException {
} else {
Version minVersion = Version.LATEST;
for (LeafReaderContext leafReaderContext : reader.leaves()) {
Version leafVersion = leafReaderContext.reader().getMetaData().getMinVersion();
Version leafVersion = leafReaderContext.reader().getMetaData().minVersion();
if (leafVersion == null) {
minVersion = null;
break;
Expand All @@ -112,14 +113,20 @@ public static LeafReader wrap(IndexReader reader) throws IOException {
LeafMetaData leafMetaData = reader.leaves().get(0).reader().getMetaData();
metaData =
new LeafMetaData(
leafMetaData.getCreatedVersionMajor(),
leafMetaData.createdVersionMajor(),
minVersion,
leafMetaData.getSort(),
leafMetaData.sort(),
leafMetaData.hasBlocks());
}
fieldInfos = FieldInfos.getMergedFieldInfos(in);
}

@Override
public DocValuesSkipper getDocValuesSkipper(String field) throws IOException {
//TODO implement skipping
return null;
}

@Override
public String toString() {
return "SlowCompositeReaderWrapper(" + in + ")";
Expand Down Expand Up @@ -312,12 +319,6 @@ public NumericDocValues getNormValues(String field) throws IOException {
return MultiDocValues.getNormValues(in, field); // TODO cache?
}

@Override
@Deprecated
public Fields getTermVectors(int docID) throws IOException {
return in.getTermVectors(docID);
}

@Override
public TermVectors termVectors() throws IOException {
ensureOpen();
Expand All @@ -342,13 +343,6 @@ public int maxDoc() {
return in.maxDoc();
}

@Override
@Deprecated
public void document(int docID, StoredFieldVisitor visitor) throws IOException {
ensureOpen();
in.document(docID, visitor);
}

@Override
public Bits getLiveDocs() {
ensureOpen();
Expand Down
Loading
Loading