mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 12:05:05 +08:00
Introduce a flag to the search subcommand to display the facet distribution
This commit is contained in:
parent
61dbcfa44a
commit
70e9b1e936
@ -29,6 +29,10 @@ pub struct Opt {
|
||||
|
||||
/// The query string to search for (doesn't support prefix search yet).
|
||||
query: Option<String>,
|
||||
|
||||
/// Compute and print the facet distribution of all the faceted fields.
|
||||
#[structopt(long)]
|
||||
print_facet_distribution: bool,
|
||||
}
|
||||
|
||||
pub fn run(opt: Opt) -> anyhow::Result<()> {
|
||||
@ -71,6 +75,12 @@ pub fn run(opt: Opt) -> anyhow::Result<()> {
|
||||
let _ = writeln!(&mut stdout);
|
||||
}
|
||||
|
||||
if opt.print_facet_distribution {
|
||||
let facets = index.facets(&rtxn).candidates(result.candidates).execute()?;
|
||||
serde_json::to_writer(&mut stdout, &facets)?;
|
||||
let _ = writeln!(&mut stdout);
|
||||
}
|
||||
|
||||
debug!("Took {:.02?} to find {} documents", before.elapsed(), result.documents_ids.len());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user