Lowercase the facet string value

This commit is contained in:
Kerollmops 2020-12-01 14:08:51 +01:00
parent 6120f6590b
commit 45877b3154
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -237,7 +237,8 @@ impl FacetCondition {
FacetType::Integer => Ok(OperatorI64(fid, Equal(pest_parse(value)?))), FacetType::Integer => Ok(OperatorI64(fid, Equal(pest_parse(value)?))),
FacetType::Float => Ok(OperatorF64(fid, Equal(pest_parse(value)?))), FacetType::Float => Ok(OperatorF64(fid, Equal(pest_parse(value)?))),
FacetType::String => { FacetType::String => {
Ok(OperatorString(fid, FacetStringOperator::Equal(value.as_str().to_string()))) let value = value.as_str().to_lowercase().to_string();
Ok(OperatorString(fid, FacetStringOperator::Equal(value)))
}, },
} }
} }
@ -563,7 +564,7 @@ mod tests {
// Test that the facet condition is correctly generated. // Test that the facet condition is correctly generated.
let rtxn = index.read_txn().unwrap(); let rtxn = index.read_txn().unwrap();
let condition = FacetCondition::from_str(&rtxn, &index, "channel = ponce").unwrap(); let condition = FacetCondition::from_str(&rtxn, &index, "channel = ponce").unwrap();
let expected = OperatorString(1, FacetStringOperator::Equal("ponce".into())); let expected = OperatorString(1, FacetStringOperator::Equal("Ponce".into()));
assert_eq!(condition, expected); assert_eq!(condition, expected);
let condition = FacetCondition::from_str(&rtxn, &index, "channel != ponce").unwrap(); let condition = FacetCondition::from_str(&rtxn, &index, "channel != ponce").unwrap();