refactoring search based on the profile
This commit is contained in:
@@ -7,14 +7,16 @@ service Searcher {
|
||||
}
|
||||
|
||||
message SearchRequest {
|
||||
string table_name = 1;
|
||||
optional string table_name = 1;
|
||||
string query = 2;
|
||||
string profile_name = 3;
|
||||
}
|
||||
message SearchResponse {
|
||||
message Hit {
|
||||
int64 id = 1; // PostgreSQL row ID
|
||||
float score = 2;
|
||||
string content_json = 3;
|
||||
string table_name = 4;
|
||||
}
|
||||
repeated Hit hits = 1;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,10 +1,12 @@
|
||||
// This file is @generated by prost-build.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct SearchRequest {
|
||||
#[prost(string, tag = "1")]
|
||||
pub table_name: ::prost::alloc::string::String,
|
||||
#[prost(string, optional, tag = "1")]
|
||||
pub table_name: ::core::option::Option<::prost::alloc::string::String>,
|
||||
#[prost(string, tag = "2")]
|
||||
pub query: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "3")]
|
||||
pub profile_name: ::prost::alloc::string::String,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct SearchResponse {
|
||||
@@ -22,6 +24,8 @@ pub mod search_response {
|
||||
pub score: f32,
|
||||
#[prost(string, tag = "3")]
|
||||
pub content_json: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "4")]
|
||||
pub table_name: ::prost::alloc::string::String,
|
||||
}
|
||||
}
|
||||
/// Generated client implementations.
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
// common/src/search.rs
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use tantivy::schema::*;
|
||||
use tantivy::tokenizer::*;
|
||||
use tantivy::Index;
|
||||
|
||||
/// Returns the on-disk path for a profile/table search index.
|
||||
pub fn search_index_path(root: &Path, profile_name: &str, table_name: &str) -> PathBuf {
|
||||
root.join(profile_name).join(table_name)
|
||||
}
|
||||
|
||||
/// Creates a hybrid Slovak search schema with optimized prefix fields.
|
||||
pub fn create_search_schema() -> Schema {
|
||||
let mut schema_builder = Schema::builder();
|
||||
|
||||
schema_builder.add_u64_field("pg_id", INDEXED | STORED);
|
||||
|
||||
// FIELD 1: For prefixes (1-4 chars).
|
||||
// For prefixes (1-4 chars).
|
||||
let short_prefix_indexing = TextFieldIndexing::default()
|
||||
.set_tokenizer("slovak_prefix_edge")
|
||||
.set_index_option(IndexRecordOption::WithFreqsAndPositions);
|
||||
@@ -19,7 +25,7 @@ pub fn create_search_schema() -> Schema {
|
||||
.set_stored();
|
||||
schema_builder.add_text_field("prefix_edge", short_prefix_options);
|
||||
|
||||
// FIELD 2: For the full word.
|
||||
// For the full word.
|
||||
let full_word_indexing = TextFieldIndexing::default()
|
||||
.set_tokenizer("slovak_prefix_full")
|
||||
.set_index_option(IndexRecordOption::WithFreqsAndPositions);
|
||||
|
||||
Reference in New Issue
Block a user