working v12
This commit is contained in:
@@ -112,6 +112,7 @@ impl SearcherService {
|
||||
|
||||
Ok(Response::new(SearchResponse { hits }))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct ProfileIndex {
|
||||
@@ -133,7 +134,7 @@ impl ProfileIndex {
|
||||
.map_err(|e| Status::internal(format!("Failed to build index reader: {}", e)))?;
|
||||
let fields = SchemaFields::from(&index.schema()).map_err(|e| {
|
||||
Status::internal(format!(
|
||||
"Search index schema mismatch. Reindex required: {}",
|
||||
"Search index schema mismatch. Delete the stale index and create it again: {}",
|
||||
e
|
||||
))
|
||||
})?;
|
||||
@@ -205,6 +206,22 @@ fn validate_identifier(value: &str, field_name: &str) -> Result<(), Status> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn validate_search_column(value: &str) -> Result<(), Status> {
|
||||
if value.is_empty() {
|
||||
return Err(Status::invalid_argument(
|
||||
"constraint.column must not be empty",
|
||||
));
|
||||
}
|
||||
|
||||
if value.chars().any(|ch| ch.is_control() || ch == '\0') {
|
||||
return Err(Status::invalid_argument(
|
||||
"constraint.column contains invalid characters",
|
||||
));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn qualify_profile_table(profile_name: &str, table_name: &str) -> String {
|
||||
format!("\"{}\".\"{}\"", profile_name, table_name)
|
||||
}
|
||||
@@ -258,12 +275,7 @@ fn normalize_request(req: SearchRequest) -> Result<NormalizedSearchRequest, Stat
|
||||
|
||||
for constraint in req.must {
|
||||
let column = constraint.column.trim();
|
||||
if column.is_empty() {
|
||||
return Err(Status::invalid_argument(
|
||||
"constraint.column must not be empty",
|
||||
));
|
||||
}
|
||||
validate_identifier(column, "constraint.column")?;
|
||||
validate_search_column(column)?;
|
||||
|
||||
let query = constraint.query.trim();
|
||||
if query.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user