column name indexing

This commit is contained in:
Priec
2026-04-29 01:33:48 +02:00
parent 036e12f345
commit fb4769301c
6 changed files with 96 additions and 50 deletions

View File

@@ -11,6 +11,7 @@ message SearchRequest {
optional string table_name = 1;
string query = 2;
string profile_name = 3;
optional string column_name = 4;
}
message SearchResponse {
message Hit {

Binary file not shown.

View File

@@ -7,6 +7,8 @@ pub struct SearchRequest {
pub query: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub profile_name: ::prost::alloc::string::String,
#[prost(string, optional, tag = "4")]
pub column_name: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SearchResponse {

View File

@@ -15,6 +15,48 @@ pub fn search_row_key(table_name: &str, row_id: i64) -> String {
format!("{}:{}", table_name, row_id)
}
/// Normalizes user-entered search text while preserving letter case.
pub fn normalize_search_text(text: &str) -> String {
text.chars()
.map(|ch| match ch {
'á' | 'à' | 'â' | 'ä' | 'ă' | 'ā' => 'a',
'Á' | 'À' | 'Â' | 'Ä' | 'Ă' | 'Ā' => 'A',
'é' | 'è' | 'ê' | 'ë' | 'ě' | 'ē' => 'e',
'É' | 'È' | 'Ê' | 'Ë' | 'Ě' | 'Ē' => 'E',
'í' | 'ì' | 'î' | 'ï' | 'ī' => 'i',
'Í' | 'Ì' | 'Î' | 'Ï' | 'Ī' => 'I',
'ó' | 'ò' | 'ô' | 'ö' | 'ō' | 'ő' => 'o',
'Ó' | 'Ò' | 'Ô' | 'Ö' | 'Ō' | 'Ő' => 'O',
'ú' | 'ù' | 'û' | 'ü' | 'ū' | 'ű' => 'u',
'Ú' | 'Ù' | 'Û' | 'Ü' | 'Ū' | 'Ű' => 'U',
'ý' | 'ỳ' | 'ŷ' | 'ÿ' => 'y',
'Ý' | 'Ỳ' | 'Ŷ' | 'Ÿ' => 'Y',
'č' => 'c',
'Č' => 'C',
'ď' => 'd',
'Ď' => 'D',
'ľ' => 'l',
'Ľ' => 'L',
'ň' => 'n',
'Ň' => 'N',
'ř' => 'r',
'Ř' => 'R',
'š' => 's',
'Š' => 'S',
'ť' => 't',
'Ť' => 'T',
'ž' => 'z',
'Ž' => 'Z',
_ => ch,
})
.collect()
}
/// Normalizes an exact-match value so indexed data and user input use the same form.
pub fn normalize_exact_value(text: &str) -> String {
normalize_search_text(text).to_lowercase()
}
/// Creates a hybrid Slovak search schema with optimized prefix fields.
pub fn create_search_schema() -> Schema {
let mut schema_builder = Schema::builder();
@@ -22,6 +64,7 @@ pub fn create_search_schema() -> Schema {
schema_builder.add_u64_field("pg_id", INDEXED | STORED);
schema_builder.add_text_field("table_name", STRING | STORED);
schema_builder.add_text_field("row_key", STRING | STORED);
schema_builder.add_text_field("column_exact", STRING);
// For prefixes (1-4 chars).
let short_prefix_indexing = TextFieldIndexing::default()