WeaviateEx.Query.NearImage (WeaviateEx v0.7.4)
View SourceImage-based vector search for multimodal collections.
Supports multi2vec-clip, multi2vec-bind, and other image vectorizers.
Examples
# Search by base64 encoded image
NearImage.new(image: base64_data)
|> Query.execute(client, "ImageCollection")
# Search by file path
NearImage.new(image_file: "/path/to/image.png", certainty: 0.8)
|> Query.execute(client, "ImageCollection")
# With named vectors
NearImage.new(image: data, target_vectors: ["image_vector"])
# Using the Query builder
Query.get("ImageCollection")
|> Query.near_image(image: base64_data, certainty: 0.8)
|> Query.fields(["name", "description"])
|> Query.execute(client)
Summary
Functions
Encode an image file to base64.
Get the base64-encoded image data, reading from file if necessary.
Create a new near_image search configuration.
Convert to GraphQL query format.
Convert to gRPC NearImageSearch format.
Types
Functions
Encode an image file to base64.
Examples
NearImage.encode_image_file("/path/to/image.png")
# => "iVBORw0KGgo..."
Get the base64-encoded image data, reading from file if necessary.
If the struct was created with :image, returns it as-is.
If the struct was created with :image_file, reads and encodes the file.
Examples
near_image = NearImage.new(image: "base64data")
NearImage.get_encoded_image(near_image)
# => "base64data"
near_image = NearImage.new(image_file: "/path/to/image.png")
NearImage.get_encoded_image(near_image)
# => "iVBORw0KGgo..." (file contents as base64)
Create a new near_image search configuration.
Options
:image- Base64-encoded image data:image_file- Path to image file (will be read and base64 encoded):certainty- Minimum certainty threshold (0.0 to 1.0):distance- Maximum distance threshold:target_vectors- List of named vectors to target
Either :image or :image_file must be provided, but not both.
Examples
NearImage.new(image: "base64encodeddata==")
NearImage.new(image_file: "/path/to/image.png", certainty: 0.8)
NearImage.new(image: data, target_vectors: ["image_vector"])
Convert to GraphQL query format.
Returns a map with string keys suitable for GraphQL nearImage queries. Nil values are excluded from the result.
Examples
near_image = NearImage.new(image: "data", distance: 0.2)
NearImage.to_graphql(near_image)
# => %{"image" => "data", "distance" => 0.2}
Convert to gRPC NearImageSearch format.
Returns a map suitable for use with the gRPC search API. Nil values are excluded from the result.
Examples
near_image = NearImage.new(image: "data", certainty: 0.8)
NearImage.to_grpc(near_image)
# => %{image: "data", certainty: 0.8}