Skip to content

Commit 1b25d63

Browse files
committed
Allow searching for multiple words
1 parent 1ef9f9a commit 1b25d63

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "nh"
3-
version = "4.0.0-beta.10"
3+
version = "4.0.0-beta.11"
44
edition = "2021"
55
license = "EUPL-1.2"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

src/interface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ pub struct SearchArgs {
181181
pub channel: String,
182182

183183
/// Name of the package to search
184-
pub query: String,
184+
pub query: Vec<String>,
185185
}
186186

187187
#[derive(Debug, Clone, ValueEnum)]

src/search.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ impl SearchArgs {
5656
.output()
5757
});
5858

59+
let query_s = self.query.join(" ");
60+
debug!(?query_s);
61+
5962
let query = Search::new().from(0).size(self.limit).query(
6063
Query::bool().filter(Query::term("type", "package")).must(
6164
Query::dis_max()
@@ -76,15 +79,15 @@ impl SearchArgs {
7679
"flake_name^0.5",
7780
"flake_name.*^0.3",
7881
],
79-
self.query.as_str(),
82+
query_s.clone(),
8083
)
8184
.r#type(TextQueryType::CrossFields)
8285
.analyzer("whitespace")
8386
.auto_generate_synonyms_phrase_query(false)
8487
.operator(Operator::And),
8588
)
8689
.query(
87-
Query::wildcard("package_attr_name", format!("*{}*", self.query))
90+
Query::wildcard("package_attr_name", format!("*{}*", &query_s))
8891
.case_insensitive(true),
8992
),
9093
),

0 commit comments

Comments
 (0)