Filter by mime
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
use pile_config::{ConfigToml, DatasetFts, Label};
|
||||
use pile_value::value::{Item, PileValue};
|
||||
use pile_value::{
|
||||
extract::traits::ExtractState,
|
||||
value::{Item, PileValue},
|
||||
};
|
||||
use std::{path::PathBuf, sync::LazyLock};
|
||||
use tantivy::{
|
||||
DocAddress, Index, ReloadPolicy, TantivyDocument, TantivyError,
|
||||
@@ -63,6 +66,7 @@ impl DbFtsIndex {
|
||||
/// Turn an entry into a tantivy document
|
||||
pub async fn entry_to_document(
|
||||
&self,
|
||||
state: &ExtractState,
|
||||
item: &Item,
|
||||
) -> Result<Option<TantivyDocument>, TantivyError> {
|
||||
let mut doc = TantivyDocument::default();
|
||||
@@ -75,7 +79,7 @@ impl DbFtsIndex {
|
||||
|
||||
let mut empty = true;
|
||||
for name in self.fts_cfg().fields.keys() {
|
||||
let x = self.get_field(&item, name).await?;
|
||||
let x = self.get_field(state, &item, name).await?;
|
||||
|
||||
let val = match x {
|
||||
Some(x) => x,
|
||||
@@ -99,6 +103,7 @@ impl DbFtsIndex {
|
||||
|
||||
pub async fn get_field(
|
||||
&self,
|
||||
state: &ExtractState,
|
||||
extractor: &PileValue,
|
||||
field_name: &Label,
|
||||
) -> Result<Option<String>, std::io::Error> {
|
||||
@@ -112,7 +117,7 @@ impl DbFtsIndex {
|
||||
|
||||
// Try paths in order, using the first value we find
|
||||
'outer: for path in field.path.as_slice() {
|
||||
let val = match extractor.query(path).await? {
|
||||
let val = match extractor.query(state, path).await? {
|
||||
Some(x) => x,
|
||||
None => return Ok(None),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user