Skip to content

Commit

Permalink
autocommit
Browse files Browse the repository at this point in the history
  • Loading branch information
nbittich committed Aug 9, 2023
1 parent 24b23cb commit 9f44fe6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index_tantivy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde::Deserialize;
use tantivy::{
collector::TopDocs,
query::{FuzzyTermQuery, Query, QueryParser, RegexQuery, TermQuery},
schema::{Field, IndexRecordOption, Schema, STORED, STRING, TEXT},
schema::{Field, IndexRecordOption, NamedFieldDocument, Schema, STORED, STRING, TEXT},
Document, Index, IndexReader, IndexWriter, ReloadPolicy, Term,
};
use tokio::sync::Mutex;
Expand Down Expand Up @@ -107,15 +107,15 @@ impl FileSearchIndex {
per_page: usize,
q: &str,
query_type: &QueryType,
) -> Result<Vec<Document>, Box<dyn Error>> {
) -> Result<Vec<NamedFieldDocument>, Box<dyn Error>> {
let schema = &self.schema;
let query = self.convert_query_type_to_query(q, query_type)?;
let searcher = &self.index_reader.searcher();
let top_docs = searcher.search(&query, &TopDocs::with_limit(per_page).and_offset(page))?;
let mut docs = Vec::with_capacity(top_docs.len());
for (_score, doc_address) in top_docs.iter() {
let retrieved_doc = searcher.doc(*doc_address)?;
docs.push(retrieved_doc);
docs.push(schema.to_named_doc(&retrieved_doc));
}
Ok(docs)
}
Expand Down

0 comments on commit 9f44fe6

Please sign in to comment.