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

Experimental syntax for nearVector search, object mapping, and partial gRPC support #351

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

bevzzz
Copy link
Collaborator

@bevzzz bevzzz commented Feb 14, 2025

Here we have a preview of the syntax we are planning for the new client implemented for a small subset of features, namely nearVector search with filtering.

All classes included in the preview are part of the client.experimental package and you can find examples of their usages in the GRPCBenchTest.java. The new search methods use gRPC to communicate with the server and show significant (anywhere between 6 to 8x) speed improvement compared to their GraphQL counterparts.

Additionally, this PR adds a buildSearchRequest() method to GraphQL's GetBuilder, so that it can be easily used in combination with client.grpc().raw().withSearchRequest() to get the performance bump without any major code changes.

bevzzz and others added 17 commits February 5, 2025 10:18
…locally

Pass lombok version to lombok-maven-plugin explicitly, as the default version is not up-to-date.
See: awhitford/lombok.maven#179 (comment)
Dataset size (n. vectors): 10
Vectors in range 0.0001-0.0010 with length: 5000
===========================================
GRPCBenchTest.testGRPC: [measured 10 out of 13 rounds, threads: 1 (sequential)]
 round: 0.19 [+- 0.00], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+- 0.00], GC.calls: 0, GC.time: 0.00, time.total: 2.77, time.warmup: 0.88, time.bench: 1.89
GRPCBenchTest.testGraphQL: [measured 10 out of 13 rounds, threads: 1 (sequential)]
 round: 0.22 [+- 0.00], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+- 0.00], GC.calls: 3, GC.time: 0.00, time.total: 2.89, time.warmup: 0.71, time.bench: 2.18
…g dependency

Dataset size (n. vectors): 10
Vectors with length: 5000 in range 0.0001-0.0010
===========================================
GRPC    (3 warmup, 10 benchmark): 4.0ms
        warmup.round: 28.0ms     total: 125ms
GraphQL (3 warmup, 10 benchmark): 32.0ms
        warmup.round: 49.0ms     total: 470ms
Updated benchmark:
[INFO] Running io.weaviate.integration.client.grpc.GRPCBenchTest
Dataset size (n. vectors): 10
Vectors with length: 5000 in range 0.0001-0.0010
===========================================
GRPC    (3 warmup, 10 benchmark): 4.0ms
        warmup.round: 26.0ms     total: 121ms
GRPC.new        (3 warmup, 10 benchmark): 3.0ms
        warmup.round: 5.0ms      total: 50ms
GraphQL (3 warmup, 10 benchmark): 31.0ms
        warmup.round: 49.0ms     total: 459ms

1) GRPC.new doesn't add any filters (neither do other queries, but we save some time on marshalling that perhaps)
2) Experimental syntax only supports nearVector search
…/or operators

Example query:
      things.query.nearVector(
          vector,
          opt -> opt
              .limit(K)
              .where(Where.and(
                  Where.property("name").eq("dyma"),
                  Where.reference("hasFriend", "hasAddress", "city").gt("Monaco"),
                  Where.or(
                      Where.property("dob").gt("1 Jan 1970"),
                      Where.property("age").gt("27"))))
              .returnProperties(fields)
              .returnMetadata(MetadataField.ID, MetadataField.VECTOR, MetadataField.DISTANCE));

Not committing this, because those filters would be invalid for the collection used in the test (only has vector, no props).
Benchmarking results unchanged for the reason above, might change later.
[INFO] Running io.weaviate.integration.client.grpc.GRPCBenchTest
Dataset size (n. vectors): 10
Vectors with length: 5000 in range 0.0001-0.0010
===========================================
GRPC    (3 warmup, 10 benchmark): 4.90ms
        warmup.round: 21.00ms    total: 112.00ms
GRPC.new        (3 warmup, 10 benchmark): 4.60ms
        warmup.round: 7.67ms     total: 69.00ms
GraphQL (3 warmup, 10 benchmark): 41.10ms
        warmup.round: 57.67ms    total: 584.00ms
**GRPC.orm**        (3 warmup, 10 benchmark): 4.80ms
        warmup.round: 9.33ms     total: 76.00ms
Where::isEmpty ensures we do not add a filter condition if no filters
were passed.
Added protobuf.java-util dependency for logging protobuf objects as
JSON (debuggging).
Copy link

@orca-security-eu orca-security-eu bot left a comment

Choose a reason for hiding this comment

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

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

List::getFirst is not introduced until Java 21
Return SearchResult<Map<String, Object>> from nearVectorUntyped
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.

1 participant