add ip field

This commit is contained in:
Pascal Seitz
2022-08-04 08:48:21 +02:00
parent f4d7621370
commit 4a1b251a08
13 changed files with 223 additions and 14 deletions

View File

@@ -400,6 +400,7 @@ impl QueryParser {
let bytes = base64::decode(phrase).map_err(QueryParserError::ExpectedBase64)?;
Ok(Term::from_field_bytes(field, &bytes))
}
FieldType::Ip(_) => Ok(Term::from_field_text(field, phrase)),
}
}
@@ -506,6 +507,13 @@ impl QueryParser {
let bytes_term = Term::from_field_bytes(field, &bytes);
Ok(vec![LogicalLiteral::Term(bytes_term)])
}
FieldType::Ip(ref option) => {
if !option.is_indexed() {
return Err(QueryParserError::FieldNotIndexed(field_name.to_string()));
}
let text_term = Term::from_field_text(field, phrase);
Ok(vec![LogicalLiteral::Term(text_term)])
}
}
}