Skip to content

v6: NearObject, Near<Media>, and Hybrid queries #396

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

Open
wants to merge 11 commits into
base: v6
Choose a base branch
from
Open

Conversation

bevzzz
Copy link
Collaborator

@bevzzz bevzzz commented Jun 24, 2025

This PR adds support for NearObject, Near, and Hybrid operators in query and aggregate namespaces.

final var things = client.collections.use("Things");

things.query.hybrid("something like that", q -> q.alpha(0.3f).fusionType(Hybrid.FusionType.RANKED));

// .excludeSelf is a shorthand for `where(Where.uuid().ne("this-thing-id"))`
things.query.nearObject("this-thing-id", q -> q.excludeSelf());

There's also some minor improvements to Where-filter builders:

  • Where.uuid() is a shorthand for Where.property("_id")
  • Where::toString now prints human-readable representation of the filter
Where.reference("hasFriend", "name").eq("Piglet")`
// Outputs:
//   "Where(hasFriend::name Equal Piglet)"
  • Calls to .where(...) can now be chained -- individual conditions will be AND'ed together
query -> query.where(Where.and(
  Where.property("name").eq("pooh"),
  Where.property("age").gte(22)
))

// is equivalent to

query -> query
  .where(Where.property("name").eq("pooh")
  .where(Where.property("age").gte(22)

@bevzzz bevzzz self-assigned this Jun 24, 2025
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 Secrets high 0   medium 0   low 0   info 0 View in Orca

bevzzz added 6 commits June 25, 2025 19:12
This allows higher-level queries like NearObject to add
filters without overwriting the ones set by users.
In general, this lets users call .where() multiple times,
in line with the principle of 'append-only' options.
Replace @see with See.
Refactor ById to use the new Where.uuid() shorthand.
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