WeaviateEx.Filter.MultiTargetRef (WeaviateEx v0.7.4)

View Source

Filter builder for multi-target reference properties.

When a reference property can point to multiple collections, use this module to filter by a specific target collection.

Examples

# Filter where "relatedTo" points to an Article with specific title
MultiTargetRef.new("relatedTo", "Article")
|> MultiTargetRef.where("title", :equal, "My Article")

# Filter where "mentions" points to a verified Person
MultiTargetRef.new("mentions", "Person")
|> MultiTargetRef.where("verified", :equal, true)

# Use with Filter combinators
Filter.all_of([
  MultiTargetRef.new("relatedTo", "Article")
  |> MultiTargetRef.where("status", :equal, "published"),
  Filter.equal("featured", true)
])

# Deep path filtering
MultiTargetRef.new("mentions", "Person")
|> MultiTargetRef.deep_where(fn path ->
  path
  |> RefPath.through("worksAt", "Company")
  |> RefPath.property("industry", :equal, "Tech")
end)

Summary

Functions

Create a reference path for chaining with RefPath.

Build a deep path filter through the multi-target reference.

Create a new multi-target reference filter builder.

Add a property filter condition.

Types

t()

@type t() :: %WeaviateEx.Filter.MultiTargetRef{
  property: String.t(),
  target: String.t()
}

Functions

as_ref_path(multi_target_ref)

@spec as_ref_path(t()) :: WeaviateEx.Filter.RefPath.t()

Create a reference path for chaining with RefPath.

Use this when you want to start a RefPath from a multi-target reference.

Examples

MultiTargetRef.new("mentions", "Person")
|> MultiTargetRef.as_ref_path()
|> RefPath.through("worksAt", "Company")
|> RefPath.property("name", :equal, "Acme")

deep_where(multi_target_ref, path_fn)

@spec deep_where(t(), (WeaviateEx.Filter.RefPath.t() -> map())) :: map()

Build a deep path filter through the multi-target reference.

Use this when you need to filter through multiple levels of references starting from a multi-target reference.

Examples

MultiTargetRef.new("mentions", "Person")
|> MultiTargetRef.deep_where(fn path ->
  path
  |> RefPath.through("worksAt", "Company")
  |> RefPath.property("industry", :equal, "Tech")
end)

new(property, target_collection)

@spec new(String.t(), String.t()) :: t()

Create a new multi-target reference filter builder.

Arguments

  • property - The multi-target reference property name
  • target_collection - The specific collection to filter on

Examples

MultiTargetRef.new("relatedTo", "Article")
MultiTargetRef.new("mentions", "Person")

where(multi_target_ref, property, operator, value)

@spec where(t(), String.t(), atom(), term()) :: map()

Add a property filter condition.

Arguments

  • ref - The MultiTargetRef struct
  • property - Property name in the target collection
  • operator - Filter operator
  • value - Filter value

Examples

MultiTargetRef.new("relatedTo", "Article")
|> MultiTargetRef.where("title", :equal, "Test")

MultiTargetRef.new("mentions", "Person")
|> MultiTargetRef.where("verified", :equal, true)