pub struct SolrGroupResult { /* private fields */ }Expand description
Struct representing a Solr Grouping response
Implementations§
Source§impl SolrGroupResult
impl SolrGroupResult
Sourcepub fn get_field_result(&self) -> Option<&[SolrGroupFieldResult]>
pub fn get_field_result(&self) -> Option<&[SolrGroupFieldResult]>
Returns a field query result
§Examples
use solrstice::{GroupingComponent, SelectQuery, SolrServerContextBuilder, SolrSingleServerHost};
let response = SelectQuery::new()
.fq(["age:[* TO *]"])
.grouping(&GroupingComponent::new().fields(["age"]).limit(10))
.execute(&context, "collection_name")
.await?;
let groups = response.get_groups().ok_or("No groups")?;
let age_group = groups.get("age").ok_or("No age group")?;
for group in age_group.get_field_result().ok_or("No field result")? {
println!("Group key: {}", group.get_group_value::<usize>()?);
let docs = group.get_doc_list().get_docs::<serde_json::Value>()?;
}Sourcepub fn get_query_result(&self) -> Option<&SolrDocsResponse>
pub fn get_query_result(&self) -> Option<&SolrDocsResponse>
Returns a grouping query result
§Examples
use solrstice::{GroupingComponent, SelectQuery, SolrSingleServerHost};
async fn run() -> Result<(), Box<dyn std::error::Error>> {
let response = SelectQuery::new()
.grouping(
&GroupingComponent::new()
.queries(["age:[0 TO 59]", "age:[60 TO *]"])
.limit(10),
)
.execute(&context, "collection_name")
.await?;
let groups = response
.get_groups().ok_or("No groups")?;
let result = groups
.get("age:[0 TO 59]").ok_or("No age group")?
.get_query_result().ok_or("No query result")?;Sourcepub fn get_simple_result(&self) -> Option<&SolrDocsResponse>
pub fn get_simple_result(&self) -> Option<&SolrDocsResponse>
If GroupFormatting::Simple is used, returns a simple grouping query result. This uses the same logic as get_query_result
§Examples
use solrstice::{GroupFormatting, GroupingComponent, SolrBasicAuth, SelectQuery, SolrServerContextBuilder, SolrSingleServerHost};
let response = SelectQuery::new()
.fq(["age:[* TO *]"])
.grouping(&GroupingComponent::new().fields(["age"]).limit(10).format(GroupFormatting::Simple))
.execute(&context, "collection_name")
.await?;
let groups = response.get_groups().ok_or("No groups")?;
let age_group = groups.get("age").ok_or("No age group")?;
let result = age_group.get_simple_result().ok_or("No field result")?;Sourcepub fn get_matches(&self) -> usize
pub fn get_matches(&self) -> usize
Returns the number of matches for the query
Sourcepub fn get_n_groups(&self) -> Option<usize>
pub fn get_n_groups(&self) -> Option<usize>
Returns the number of groups for the query, if n_groups was given
Trait Implementations§
Source§impl Clone for SolrGroupResult
impl Clone for SolrGroupResult
Source§fn clone(&self) -> SolrGroupResult
fn clone(&self) -> SolrGroupResult
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SolrGroupResult
impl Debug for SolrGroupResult
Source§impl<'de> Deserialize<'de> for SolrGroupResult
impl<'de> Deserialize<'de> for SolrGroupResult
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SolrGroupResult
impl RefUnwindSafe for SolrGroupResult
impl Send for SolrGroupResult
impl Sync for SolrGroupResult
impl Unpin for SolrGroupResult
impl UnwindSafe for SolrGroupResult
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more