Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7f3e505

Browse files
authored
Added search tags filtering (#1355)
1 parent4c301ca commit7f3e505

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

‎pgml-dashboard/src/api/cms.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,10 @@ impl Collection {
625625

626626
#[get("/search?<query>", rank =20)]
627627
asyncfnsearch(query:&str,site_search:&State<crate::utils::markdown::SiteSearch>) ->ResponseOk{
628-
let results = site_search.search(query,None).await.expect("Error performing search");
628+
let results = site_search
629+
.search(query,None,None)
630+
.await
631+
.expect("Error performing search");
629632

630633
let results:Vec<SearchResult> = results
631634
.into_iter()

‎pgml-dashboard/src/utils/markdown.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,12 @@ impl SiteSearch {
12861286
.collect()
12871287
}
12881288

1289-
pubasyncfnsearch(&self,query:&str,doc_type:Option<DocType>) -> anyhow::Result<Vec<Document>>{
1289+
pubasyncfnsearch(
1290+
&self,
1291+
query:&str,
1292+
doc_type:Option<DocType>,
1293+
doc_tags:Option<Vec<String>>,
1294+
) -> anyhow::Result<Vec<Document>>{
12901295
letmut search = serde_json::json!({
12911296
"query":{
12921297
// "full_text_search": {
@@ -1317,11 +1322,17 @@ impl SiteSearch {
13171322
},
13181323
"limit":10
13191324
});
1325+
search["query"]["filter"]["$and"] = serde_json::json!({});
13201326
ifletSome(doc_type) = doc_type{
1321-
search["query"]["filter"]["doc_type"] = serde_json::json!({
1327+
search["query"]["filter"]["$and"]["doc_type"] = serde_json::json!({
13221328
"$eq": doc_type
13231329
});
13241330
}
1331+
ifletSome(doc_tags) = doc_tags{
1332+
search["query"]["filter"]["$and"]["tags"] = serde_json::json!({
1333+
"$in": doc_tags
1334+
});
1335+
}
13251336
let results =self.collection.search_local(search.into(),&self.pipeline).await?;
13261337

13271338
results["results"]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp