mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-27 08:41:00 +00:00
Fix parsing
This commit is contained in:
@ -241,7 +241,7 @@ impl<'a> Filter<'a> {
|
|||||||
|
|
||||||
let attribute = fid.value();
|
let attribute = fid.value();
|
||||||
if matching_features(attribute, &filterable_attributes_rules)
|
if matching_features(attribute, &filterable_attributes_rules)
|
||||||
.is_some_and(|(_, features)| features.is_filterable())
|
.is_some_and(|(_, features)| features.is_filterable()) || VectorFilter::matches(attribute)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -546,7 +546,12 @@ impl<'a> Filter<'a> {
|
|||||||
}
|
}
|
||||||
FilterCondition::Condition { fid, op } => {
|
FilterCondition::Condition { fid, op } => {
|
||||||
let value = fid.value();
|
let value = fid.value();
|
||||||
if VectorFilter::matches(value, op) {
|
if VectorFilter::matches(value) {
|
||||||
|
if !matches!(op, Condition::Exists) {
|
||||||
|
return Err(Error::UserError(UserError::InvalidFilter(
|
||||||
|
String::from("Vector filter can only be used with the `exists` operator"),
|
||||||
|
)));
|
||||||
|
}
|
||||||
let vector_filter = VectorFilter::parse(value)?;
|
let vector_filter = VectorFilter::parse(value)?;
|
||||||
return vector_filter.evaluate(rtxn, index, universe);
|
return vector_filter.evaluate(rtxn, index, universe);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
use filter_parser::Condition;
|
|
||||||
use roaring::RoaringBitmap;
|
use roaring::RoaringBitmap;
|
||||||
|
|
||||||
use crate::error::{Error, UserError};
|
use crate::error::{Error, UserError};
|
||||||
@ -13,15 +12,14 @@ pub(super) struct VectorFilter<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> VectorFilter<'a> {
|
impl<'a> VectorFilter<'a> {
|
||||||
pub(super) fn matches(value: &str, op: &Condition) -> bool {
|
pub(super) fn matches(value: &str) -> bool {
|
||||||
matches!(op, Condition::Exists) && (value.starts_with("_vectors.") || value == "_vectors")
|
value.starts_with("_vectors.") || value == "_vectors"
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses a vector filter string.
|
/// Parses a vector filter string.
|
||||||
///
|
///
|
||||||
/// Valid formats:
|
/// Valid formats:
|
||||||
/// - `_vectors`
|
/// - `_vectors`
|
||||||
/// - `_vectors.userProvided`
|
|
||||||
/// - `_vectors.{embedder_name}`
|
/// - `_vectors.{embedder_name}`
|
||||||
/// - `_vectors.{embedder_name}.userProvided`
|
/// - `_vectors.{embedder_name}.userProvided`
|
||||||
/// - `_vectors.{embedder_name}.fragments.{fragment_name}`
|
/// - `_vectors.{embedder_name}.fragments.{fragment_name}`
|
||||||
|
Reference in New Issue
Block a user