WeaviateEx.Filter.RefPath (WeaviateEx v0.7.4)
View SourceFluent API for building deep reference path filters.
Allows filtering through chains of references to reach nested properties. This enables complex filtering scenarios where you need to filter based on properties of objects that are multiple reference hops away.
Examples
# Filter articles where the author's company is in technology
RefPath.through("hasAuthor", "Author")
|> RefPath.through("worksAt", "Company")
|> RefPath.property("industry", :equal, "Technology")
# Filter by author name
RefPath.through("hasAuthor", "Author")
|> RefPath.property("name", :like, "John*")
# Use with Filter combinators
Filter.all_of([
RefPath.through("hasAuthor", "Author")
|> RefPath.property("verified", :equal, true),
Filter.equal("status", "published")
])
Summary
Functions
Build the full path list from segments.
Get the number of hops in the reference path.
Terminate the path with a property filter.
Start a reference path with the first reference.
Continue a reference path with another reference hop.
Get the path without a final property.
Types
Functions
Build the full path list from segments.
Examples
segments = [{"hasAuthor", "Author"}, {"worksAt", "Company"}]
RefPath.build_path(segments, "name")
#=> ["hasAuthor", "Author", "worksAt", "Company", "name"]
@spec depth(t()) :: non_neg_integer()
Get the number of hops in the reference path.
Examples
RefPath.through("hasAuthor", "Author")
|> RefPath.through("worksAt", "Company")
|> RefPath.depth()
#=> 2
Terminate the path with a property filter.
Creates a filter that can be used with WeaviateEx.Filter combinators.
Arguments
ref_path- The reference path built withthrough/2property- Final property name to filter onoperator- Filter operator (:equal,:greater_than, etc.)value- Filter value
Examples
RefPath.through("hasAuthor", "Author")
|> RefPath.property("name", :equal, "John")
RefPath.through("hasAuthor", "Author")
|> RefPath.through("worksAt", "Company")
|> RefPath.property("industry", :equal, "Technology")
Start a reference path with the first reference.
Arguments
property- Reference property nametarget_collection- Target collection name
Examples
RefPath.through("hasAuthor", "Author")
Continue a reference path with another reference hop.
Arguments
ref_path- Existing reference pathproperty- Reference property nametarget_collection- Target collection name
Examples
RefPath.through("hasAuthor", "Author")
|> RefPath.through("worksAt", "Company")
Get the path without a final property.
Useful for reference count filters or other operations that don't need a final property.
Examples
path = RefPath.through("hasAuthor", "Author")
RefPath.to_path(path)
#=> ["hasAuthor", "Author"]