add sort result struct

This commit is contained in:
mpostma 2020-05-07 19:25:18 +02:00
parent a88f6c3241
commit effbb7f7f1
7 changed files with 194 additions and 69 deletions

View file

@ -1,10 +1,11 @@
use std::borrow::Cow;
use std::collections::HashMap;
use heed::{RwTxn, RoTxn, Result as ZResult};
use heed::{RwTxn, RoTxn, Result as ZResult, RoRange};
use sdset::{SetBuf, Set, SetOperation};
use meilisearch_types::DocumentId;
use meilisearch_schema::FieldId;
use crate::database::MainT;
use crate::facets::FacetKey;
@ -22,6 +23,10 @@ impl Facets {
self.facets.put(writer, &facet_key, doc_ids)
}
pub fn field_document_ids<'txn>(&self, reader: &'txn RoTxn<MainT>, field_id: FieldId) -> ZResult<RoRange<'txn, FacetKey, CowSet<DocumentId>>> {
self.facets.prefix_iter(reader, &FacetKey::new(field_id, "".to_string()))
}
pub fn facet_document_ids<'txn>(&self, reader: &'txn RoTxn<MainT>, facet_key: &FacetKey) -> ZResult<Option<Cow<'txn, Set<DocumentId>>>> {
self.facets.get(reader, &facet_key)
}

View file

@ -363,10 +363,10 @@ impl Index {
QueryBuilder::new(self)
}
pub fn query_builder_with_criteria<'c, 'f, 'd, 'fa, 'i>(
pub fn query_builder_with_criteria<'c, 'f, 'd, 'fa, 'i, 'q>(
&'i self,
criteria: Criteria<'c>,
) -> QueryBuilder<'c, 'f, 'd, 'fa, 'i> {
) -> QueryBuilder<'c, 'f, 'd, 'i, 'q> {
QueryBuilder::with_criteria(self, criteria)
}
}