.
This commit is contained in:
+1
-1
@@ -41,7 +41,7 @@ impl DocType {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_named_node<'a>(node: impl Into<NamedNodeRef<'a>>) -> Option<Self> {
|
||||
pub fn try_from_named_node<'a>(node: impl Into<NamedNodeRef<'a>>) -> Option<Self> {
|
||||
let node = node.into();
|
||||
match node {
|
||||
vocab::rdf::PROPERTY => Some(DocType::RdfProperty),
|
||||
|
||||
+2
-3
@@ -5,7 +5,6 @@ use oxigraph::sparql::{QueryResults, SparqlEvaluator};
|
||||
use oxigraph::store::Store;
|
||||
use tantivy::IndexWriter;
|
||||
use tantivy::schema::{Field, OwnedValue};
|
||||
use tracing::debug;
|
||||
use gl_graph::{vocab, CurieHelper};
|
||||
use crate::DocType;
|
||||
use crate::language::LanguageCondition;
|
||||
@@ -68,7 +67,7 @@ pub fn index_entity(dataset: &Dataset, language: &LanguageCondition, writer: &In
|
||||
let mut counter = 0usize;
|
||||
for (subject, types) in subject_type_map {
|
||||
for type_ in types {
|
||||
if let Some(doc_type) = term_ref_as_named_node(type_).and_then(DocType::from_named_node) {
|
||||
if let Some(doc_type) = term_ref_as_named_node(type_).and_then(DocType::try_from_named_node) {
|
||||
let mut doc = match doc_type {
|
||||
DocType::Person => index_person(dataset, subject, language),
|
||||
DocType::CorporateBody => index_corporate_body(dataset, subject, language),
|
||||
@@ -170,7 +169,7 @@ pub fn index_schema(store: Store, language: &LanguageCondition, writer: &IndexWr
|
||||
|
||||
let discriminant = solution.get("class")
|
||||
.and_then(term_to_named_node)
|
||||
.and_then(DocType::from_named_node)
|
||||
.and_then(DocType::try_from_named_node)
|
||||
.map(|doc_type| doc_type as u64)
|
||||
.map(OwnedValue::U64)
|
||||
.unwrap_or(OwnedValue::Null);
|
||||
|
||||
Reference in New Issue
Block a user