WeaviateEx.Filter.MultiTargetRef (WeaviateEx v0.7.4)
View SourceFilter 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
Functions
@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")
@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)
Create a new multi-target reference filter builder.
Arguments
property- The multi-target reference property nametarget_collection- The specific collection to filter on
Examples
MultiTargetRef.new("relatedTo", "Article")
MultiTargetRef.new("mentions", "Person")
Add a property filter condition.
Arguments
ref- The MultiTargetRef structproperty- Property name in the target collectionoperator- Filter operatorvalue- Filter value
Examples
MultiTargetRef.new("relatedTo", "Article")
|> MultiTargetRef.where("title", :equal, "Test")
MultiTargetRef.new("mentions", "Person")
|> MultiTargetRef.where("verified", :equal, true)