mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 16:50:48 +00:00
Merge pull request #44600 from azat/fuzzy-search-prefix
Use already written part of the query for fuzzy search (pass to skim)
This commit is contained in:
commit
2e315b55f2
@ -402,10 +402,11 @@ ReplxxLineReader::ReplxxLineReader(
|
|||||||
words.push_back(hs.get().text());
|
words.push_back(hs.get().text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string current_query(rx.get_state().text());
|
||||||
std::string new_query;
|
std::string new_query;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
new_query = std::string(skim(words));
|
new_query = std::string(skim(current_query, words));
|
||||||
}
|
}
|
||||||
catch (const std::exception & e)
|
catch (const std::exception & e)
|
||||||
{
|
{
|
||||||
|
@ -87,4 +87,4 @@ private:
|
|||||||
} // namespace cxxbridge1
|
} // namespace cxxbridge1
|
||||||
} // namespace rust
|
} // namespace rust
|
||||||
|
|
||||||
::rust::String skim(::std::vector<::std::string> const &words);
|
::rust::String skim(::std::string const &prefix, ::std::vector<::std::string> const &words);
|
||||||
|
@ -5,7 +5,7 @@ use cxx::{CxxString, CxxVector};
|
|||||||
#[cxx::bridge]
|
#[cxx::bridge]
|
||||||
mod ffi {
|
mod ffi {
|
||||||
extern "Rust" {
|
extern "Rust" {
|
||||||
fn skim(words: &CxxVector<CxxString>) -> Result<String>;
|
fn skim(prefix: &CxxString, words: &CxxVector<CxxString>) -> Result<String>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ impl SkimItem for Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn skim(words: &CxxVector<CxxString>) -> Result<String, String> {
|
fn skim(prefix: &CxxString, words: &CxxVector<CxxString>) -> Result<String, String> {
|
||||||
// Let's check is terminal available. To avoid panic.
|
// Let's check is terminal available. To avoid panic.
|
||||||
if let Err(err) = TermInfo::from_env() {
|
if let Err(err) = TermInfo::from_env() {
|
||||||
return Err(format!("{}", err));
|
return Err(format!("{}", err));
|
||||||
@ -26,6 +26,7 @@ fn skim(words: &CxxVector<CxxString>) -> Result<String, String> {
|
|||||||
|
|
||||||
let options = SkimOptionsBuilder::default()
|
let options = SkimOptionsBuilder::default()
|
||||||
.height(Some("30%"))
|
.height(Some("30%"))
|
||||||
|
.query(Some(prefix.to_str().unwrap()))
|
||||||
.tac(true)
|
.tac(true)
|
||||||
.tiebreak(Some("-score".to_string()))
|
.tiebreak(Some("-score".to_string()))
|
||||||
.build()
|
.build()
|
||||||
|
Loading…
Reference in New Issue
Block a user