Skip to content

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

Merged
bevzzz merged 29 commits intomainfrom
spike/near-vector-grpc
Feb 19, 2025
Merged

Experimental syntax for nearVector search, object mapping, and partial gRPC support#351
bevzzz merged 29 commits intomainfrom
spike/near-vector-grpc

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

@bevzzz bevzzz force-pushed the spike/near-vector-grpc branch from 110ca82 to 615ab0b Compare February 17, 2025 18:45
These tests depend on the CPUs and the configuration of the host, e.g. they aren't failing on an M4 Mac
but are failing in the pipeline. They need additional investigation, which we will do before v5.1.0.
@bevzzz bevzzz force-pushed the spike/near-vector-grpc branch from 615ab0b to b767535 Compare February 18, 2025 07:53
Server returns error:
UNKNOWN: explorer: get class: concurrentTargetVector
Search): explorer: get class: vector search: object vector search at index things: s
hard things_JlFtZoNmwIqT: build inverted filter allow list: nested query: nested cla
use at pos 1: expected value to be string, got '[]string'
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 1 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
🛡️ The following SAST misconfigurations have been detected
NAME FILE
info Sensitive Information Logging in Android Applications ...l/SearchOptions.java View in code

Somehow, CONTAINS_ANY fails with the same error as EQUAL.
Needs further invertigation, not critical for alpha.
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

@bevzzz bevzzz merged commit 4da532d into main Feb 19, 2025
5 checks passed
@bevzzz bevzzz deleted the spike/near-vector-grpc branch February 19, 2025 13:27
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