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

fix sort by string when the value is null #820

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

taoyyu
Copy link
Contributor

@taoyyu taoyyu commented Feb 4, 2025

Fix
java.lang.NullPointerException
at com.yelp.nrtsearch.server.grpc.SearchResponse$Hit$FieldValue$Builder.setTextValue(SearchResponse.java:4685)
at com.yelp.nrtsearch.server.luceneserver.search.sort.SortParser.getValueForSortField(SortParser.java:202)
at com.yelp.nrtsearch.server.luceneserver.search.sort.SortParser.lambda$static$0(SortParser.java:41)
at com.yelp.nrtsearch.server.luceneserver.search.sort.SortParser.getAllSortedValues(SortParser.java:125)
at com.yelp.nrtsearch.server.luceneserver.search.collectors.SortFieldCollector.fillHitRanking(SortFieldCollector.java:84)
at com.yelp.nrtsearch.server.luceneserver.SearchHandler.setResponseHits(SearchHandler.java:516)
at com.yelp.nrtsearch.server.luceneserver.SearchHandler.handle(SearchHandler.java:233)
at com.yelp.nrtsearch.server.grpc.LuceneServer$LuceneServerImpl.search(LuceneServer.java:1076)
at com.yelp.nrtsearch.server.grpc.LuceneServerGrpc$MethodHandlers.invoke(LuceneServerGrpc.java:3376)
at io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener.onHalfClose(ServerCalls.java:182)
at io.grpc.PartialForwardingServerCallListener.onHalfClose(PartialForwardingServerCallListener.java:35)
at io.grpc.ForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:23)
at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.halfClosed(ServerCallImpl.java:340)
at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed.runInContext(ServerImpl.java:866)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1583)}

Need to backport to v0.x for deployment

Copy link
Contributor

@aprudhomme aprudhomme left a comment

Choose a reason for hiding this comment

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

This should have tests to ensure it completely fixes the problem. Also, how will this be handled when building LastHitInfo and performing a searchAfter?

Comment on lines +199 to +201
if (sortValue == null) {
fieldValue.setTextValue("");
} else if (sortValue instanceof BytesRef) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this condition happen for more than just string fields? How can you distinguish between a unset field and one set with an empty string? Should this return an empty CompositeFieldValue instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try return empty CompositeFieldValue and add tests to see if it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants