.
This commit is contained in:
Generated
+10
@@ -1580,6 +1580,14 @@ version = "0.32.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7"
|
checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gl-graph"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"oxigraph",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gl-publisher"
|
name = "gl-publisher"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -1587,6 +1595,7 @@ dependencies = [
|
|||||||
"clap",
|
"clap",
|
||||||
"color-eyre",
|
"color-eyre",
|
||||||
"csv",
|
"csv",
|
||||||
|
"gl-graph",
|
||||||
"gl-search",
|
"gl-search",
|
||||||
"http",
|
"http",
|
||||||
"iced",
|
"iced",
|
||||||
@@ -1608,6 +1617,7 @@ name = "gl-search"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
|
"gl-graph",
|
||||||
"oxigraph",
|
"oxigraph",
|
||||||
"oxilangtag",
|
"oxilangtag",
|
||||||
"subtitler",
|
"subtitler",
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = [
|
members = [
|
||||||
|
"graph",
|
||||||
"publish",
|
"publish",
|
||||||
"search",
|
"search",
|
||||||
]
|
]
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
|
gl-graph = { path = "graph" }
|
||||||
gl-search = { path = "search" }
|
gl-search = { path = "search" }
|
||||||
ldp = { path = "../../ldp/ldp", features = ["keyed"] }
|
ldp = { path = "../../ldp/ldp", features = ["keyed"] }
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "gl-graph"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
oxigraph.workspace = true
|
||||||
|
tracing.workspace = true
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
use std::collections::BTreeMap;
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
use oxigraph::model::{GraphNameRef, NamedNodeRef};
|
||||||
|
use tracing::debug;
|
||||||
|
|
||||||
|
const ONTOLOGY_PREFIX: &str = "https://graphofliberty.org/2026/04/ont/";
|
||||||
|
const ONTOLOGY_GRAPH_NAME: GraphNameRef = GraphNameRef::NamedNode(NamedNodeRef::new_unchecked("https://graphofliberty.org/2026/04/ont"));
|
||||||
|
|
||||||
|
pub static PREFIXES: LazyLock<BTreeMap<String, String>> = LazyLock::new(|| {
|
||||||
|
BTreeMap::from_iter([
|
||||||
|
("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"),
|
||||||
|
("rdfs", "http://www.w3.org/2000/01/rdf-schema#"),
|
||||||
|
("owl", "http://www.w3.org/2002/07/owl#"),
|
||||||
|
("xsd", "http://www.w3.org/2001/XMLSchema#"),
|
||||||
|
("ldp", "http://www.w3.org/ns/ldp#"),
|
||||||
|
("dc", "http://purl.org/dc/elements/1.1/"),
|
||||||
|
("posix", "http://www.w3.org/ns/posix/stat#"),
|
||||||
|
(
|
||||||
|
"ebucore",
|
||||||
|
"http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#",
|
||||||
|
),
|
||||||
|
("prov", "http://www.w3.org/ns/prov#"),
|
||||||
|
("locid", "http://id.loc.gov/vocabulary/identifiers/"),
|
||||||
|
("loclang", "http://id.loc.gov/vocabulary/languages/"),
|
||||||
|
("premis", "http://www.loc.gov/premis/rdf/v1#"),
|
||||||
|
("premis3", "http://www.loc.gov/premis/rdf/v3/"),
|
||||||
|
("dcterms", "http://purl.org/dc/terms/"),
|
||||||
|
("fedora", "http://fedora.info/definitions/v4/repository#"),
|
||||||
|
("rdaa", "http://rdaregistry.info/Elements/a/"),
|
||||||
|
("rdac", "http://rdaregistry.info/Elements/c/"),
|
||||||
|
("rdae", "http://rdaregistry.info/Elements/e/"),
|
||||||
|
("rdai", "http://rdaregistry.info/Elements/i/"),
|
||||||
|
("rdam", "http://rdaregistry.info/Elements/m/"),
|
||||||
|
("rdan", "http://rdaregistry.info/Elements/n/"),
|
||||||
|
("rdap", "http://rdaregistry.info/Elements/p/"),
|
||||||
|
("rdaf", "http://rdaregistry.info/Elements/rof/"),
|
||||||
|
("rdat", "http://rdaregistry.info/Elements/t/"),
|
||||||
|
("rdau", "http://rdaregistry.info/Elements/u/"),
|
||||||
|
("rdaw", "http://rdaregistry.info/Elements/w/"),
|
||||||
|
("rdax", "http://rdaregistry.info/Elements/x/"),
|
||||||
|
("rdaco", "http://rdaregistry.info/termList/RDAContentType/"),
|
||||||
|
("rdact", "http://rdaregistry.info/termList/RDACarrierType/"),
|
||||||
|
("rdamt", "http://rdaregistry.info/termList/RDAMediaType/"),
|
||||||
|
("rdaft", "http://rdaregistry.info/termList/fileType/"),
|
||||||
|
("schema", "https://schema.org/"),
|
||||||
|
("gl", "http://fedora.quill.lan/rest/"),
|
||||||
|
("glo", ONTOLOGY_PREFIX),
|
||||||
|
].map(|(k, v)| (k.to_string(), v.to_string())))
|
||||||
|
});
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct CurieHelper {
|
||||||
|
prefixes: BTreeMap<String, String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CurieHelper {
|
||||||
|
pub fn new(prefixes: BTreeMap<String, String>) -> Self {
|
||||||
|
Self {
|
||||||
|
prefixes,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn abbreviate(&self, base: Option<&str>, iri: &str) -> Option<String> {
|
||||||
|
if let Some(base) = base && let Some(local_name) = iri.strip_prefix(base) {
|
||||||
|
return Some(format!(":{local_name}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (name, base) in &self.prefixes {
|
||||||
|
if let Some(local_name) = iri.strip_prefix(base) {
|
||||||
|
return Some(format!("{name}:{local_name}"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn expand(&self, base: Option<&str>, abbreviated_iri: &str) -> Option<String> {
|
||||||
|
let (prefix, name) = abbreviated_iri.split_once(':')?;
|
||||||
|
|
||||||
|
if prefix == "" && let Some(base) = base {
|
||||||
|
Some(format!("{base}{name}"))
|
||||||
|
} else {
|
||||||
|
self.prefixes
|
||||||
|
.get(prefix)
|
||||||
|
.map(|base| format!("{base}{name}"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
mod curie;
|
||||||
|
pub mod vocab;
|
||||||
|
|
||||||
|
pub use curie::{PREFIXES, CurieHelper};
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
pub use oxigraph::model::vocab::rdf;
|
||||||
|
pub use oxigraph::model::vocab::rdfs;
|
||||||
|
|
||||||
|
pub mod gl {
|
||||||
|
use oxigraph::model::NamedNodeRef;
|
||||||
|
|
||||||
|
pub const TEMPLATE: NamedNodeRef =
|
||||||
|
NamedNodeRef::new_unchecked("https://graphofliberty.org/2026/04/ont/template");
|
||||||
|
|
||||||
|
pub const INDEXED_BY_FIELD: NamedNodeRef =
|
||||||
|
NamedNodeRef::new_unchecked("https://graphofliberty.org/2026/04/ont/indexedByField");
|
||||||
|
|
||||||
|
pub const CATEGORY_ID: NamedNodeRef =
|
||||||
|
NamedNodeRef::new_unchecked("https://graphofliberty.org/2026/04/ont/categoryId");
|
||||||
|
|
||||||
|
pub const SEARCHABLE_CLASS: NamedNodeRef =
|
||||||
|
NamedNodeRef::new_unchecked("https://graphofliberty.org/2026/04/ont/SearchableClass");
|
||||||
|
|
||||||
|
pub const ENTITY: NamedNodeRef =
|
||||||
|
NamedNodeRef::new_unchecked("https://graphofliberty.org/2026/04/ont/Entity");
|
||||||
|
|
||||||
|
pub const ASSOCIATED_PROPERTY: NamedNodeRef =
|
||||||
|
NamedNodeRef::new_unchecked("https://graphofliberty.org/2026/04/ont/associatedProperty");
|
||||||
|
|
||||||
|
pub const READ_ONLY: NamedNodeRef =
|
||||||
|
NamedNodeRef::new_unchecked("https://graphofliberty.org/2026/04/ont/readOnly");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod skos {
|
||||||
|
use oxigraph::model::NamedNodeRef;
|
||||||
|
|
||||||
|
pub const CONCEPT: NamedNodeRef =
|
||||||
|
NamedNodeRef::new_unchecked("http://www.w3.org/2004/02/skos/core#Concept");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod owl {
|
||||||
|
use oxigraph::model::NamedNodeRef;
|
||||||
|
|
||||||
|
pub const SAME_AS: NamedNodeRef =
|
||||||
|
NamedNodeRef::new_unchecked("http://www.w3.org/2002/07/owl#sameAs");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod rdac {
|
||||||
|
use oxigraph::model::NamedNodeRef;
|
||||||
|
|
||||||
|
pub const PERSON: NamedNodeRef =
|
||||||
|
NamedNodeRef::new_unchecked("http://rdaregistry.info/Elements/c/C10004");
|
||||||
|
|
||||||
|
pub const CORPORATE_BODY: NamedNodeRef =
|
||||||
|
NamedNodeRef::new_unchecked("http://rdaregistry.info/Elements/c/C10005");
|
||||||
|
|
||||||
|
pub const WORK: NamedNodeRef =
|
||||||
|
NamedNodeRef::new_unchecked("http://rdaregistry.info/Elements/c/C10001");
|
||||||
|
|
||||||
|
pub const EXPRESSION: NamedNodeRef =
|
||||||
|
NamedNodeRef::new_unchecked("http://rdaregistry.info/Elements/c/C10006");
|
||||||
|
|
||||||
|
pub const MANIFESTATION: NamedNodeRef =
|
||||||
|
NamedNodeRef::new_unchecked("http://rdaregistry.info/Elements/c/C10007");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod rdaad {
|
||||||
|
use oxigraph::model::NamedNodeRef;
|
||||||
|
|
||||||
|
pub const GIVEN_NAME: NamedNodeRef =
|
||||||
|
NamedNodeRef::new_unchecked("http://rdaregistry.info/Elements/a/datatype/P50292");
|
||||||
|
|
||||||
|
pub const SURNAME: NamedNodeRef =
|
||||||
|
NamedNodeRef::new_unchecked("http://rdaregistry.info/Elements/a/datatype/P50291");
|
||||||
|
|
||||||
|
pub const NAME_OF_CORPORATE_BODY: NamedNodeRef =
|
||||||
|
NamedNodeRef::new_unchecked("http://rdaregistry.info/Elements/a/datatype/P50032");
|
||||||
|
}
|
||||||
+2
-2
@@ -4,15 +4,15 @@ version = "0.1.0"
|
|||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
#gl-ldp.workspace = true
|
gl-graph.workspace = true
|
||||||
gl-search.workspace = true
|
gl-search.workspace = true
|
||||||
ldp.workspace = true
|
|
||||||
|
|
||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
color-eyre.workspace = true
|
color-eyre.workspace = true
|
||||||
csv = "1.4"
|
csv = "1.4"
|
||||||
http.workspace = true
|
http.workspace = true
|
||||||
iced.workspace = true
|
iced.workspace = true
|
||||||
|
ldp.workspace = true
|
||||||
rfd.workspace = true
|
rfd.workspace = true
|
||||||
oxigraph.workspace = true
|
oxigraph.workspace = true
|
||||||
oxilangtag.workspace = true
|
oxilangtag.workspace = true
|
||||||
|
|||||||
+4
-4
@@ -1,12 +1,11 @@
|
|||||||
use crate::navigator::Navigator;
|
use crate::navigator::Navigator;
|
||||||
use crate::rdf::curie::CurieHelper;
|
|
||||||
use crate::rdf::ontology::{LabeledIri, Ontology};
|
use crate::rdf::ontology::{LabeledIri, Ontology};
|
||||||
use crate::rdf::term_helper::{TermHelper, TermHelperMut};
|
use crate::rdf::term_helper::{TermHelper, TermHelperMut};
|
||||||
use crate::rdf::vocab::rda;
|
|
||||||
use crate::widget::iri_input::iri_input;
|
use crate::widget::iri_input::iri_input;
|
||||||
use crate::widget::navigation_area::navigation_area;
|
use crate::widget::navigation_area::navigation_area;
|
||||||
|
use gl_graph::vocab::rdac;
|
||||||
use gl_search::language;
|
use gl_search::language;
|
||||||
use gl_search::{IndexWriter, Schema, SearchDocument, SearchIndex, Value};
|
use gl_search::{Schema, SearchDocument, SearchIndex, Value};
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use iced::alignment::Horizontal;
|
use iced::alignment::Horizontal;
|
||||||
use iced::keyboard::{Event, key};
|
use iced::keyboard::{Event, key};
|
||||||
@@ -25,6 +24,7 @@ use oxigraph::io::RdfFormat;
|
|||||||
use oxigraph::model::vocab::{rdf, rdfs};
|
use oxigraph::model::vocab::{rdf, rdfs};
|
||||||
use oxigraph::model::{BaseDirection, Dataset, NamedNode, NamedOrBlankNode, Quad, Term};
|
use oxigraph::model::{BaseDirection, Dataset, NamedNode, NamedOrBlankNode, Quad, Term};
|
||||||
use tracing::{debug_span, error, trace};
|
use tracing::{debug_span, error, trace};
|
||||||
|
use gl_graph::{vocab, CurieHelper};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(crate) enum Message {
|
pub(crate) enum Message {
|
||||||
@@ -816,7 +816,7 @@ impl Publisher {
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let body: Element<Message> = if self.show_new_document_buttons {
|
let body: Element<Message> = if self.show_new_document_buttons {
|
||||||
let subclasses = self.ontology.subclasses_of(&rda::ENTITY.into_owned());
|
let subclasses = Vec::new(); // TODO self.ontology.subclasses_of(vocab::rda::ENTITY.into_owned());
|
||||||
let labeled_subclasses = subclasses.iter().map(|iri| self.ontology.info(iri, &*language::ENGLISH_OR_UNTAGGED));
|
let labeled_subclasses = subclasses.iter().map(|iri| self.ontology.info(iri, &*language::ENGLISH_OR_UNTAGGED));
|
||||||
column![self.view_new_entity_buttons(labeled_subclasses)].into()
|
column![self.view_new_entity_buttons(labeled_subclasses)].into()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+11
-50
@@ -7,26 +7,20 @@ mod navigator;
|
|||||||
mod theme;
|
mod theme;
|
||||||
mod args;
|
mod args;
|
||||||
|
|
||||||
use std::sync::{Arc, RwLock};
|
|
||||||
use std::thread;
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use color_eyre::eyre::eyre;
|
|
||||||
use iced::futures::StreamExt;
|
use iced::futures::StreamExt;
|
||||||
use iced::Task;
|
|
||||||
use ldp::middleware::BasicAuthMiddleware;
|
use ldp::middleware::BasicAuthMiddleware;
|
||||||
use ldp::reqwest::{Client, Url};
|
use ldp::reqwest::{Client, Url};
|
||||||
use ldp::reqwest_middleware::ClientBuilder;
|
use ldp::reqwest_middleware::ClientBuilder;
|
||||||
use ldp::traverse::Traverse;
|
use ldp::traverse::Traverse;
|
||||||
use oxigraph::model::Dataset;
|
|
||||||
use tracing::{debug, debug_span, error, field};
|
use tracing::{debug, debug_span, error, field};
|
||||||
use crate::app::{Message, Publisher};
|
use crate::app::Publisher;
|
||||||
use tracing_subscriber::layer::SubscriberExt;
|
use tracing_subscriber::layer::SubscriberExt;
|
||||||
use tracing_subscriber::util::SubscriberInitExt;
|
use tracing_subscriber::util::SubscriberInitExt;
|
||||||
use tracing_subscriber::{EnvFilter, fmt};
|
use tracing_subscriber::{EnvFilter, fmt};
|
||||||
use tracing_subscriber::fmt::format::FmtSpan;
|
use tracing_subscriber::fmt::format::FmtSpan;
|
||||||
use gl_search::{DocType, Document, Schema, SearchIndex};
|
use gl_search::{Document, Schema, SearchIndex};
|
||||||
use crate::args::{AppArgs, Command};
|
use crate::args::{AppArgs, Command};
|
||||||
use crate::rdf::curie::CurieHelper;
|
|
||||||
use crate::rdf::ontology::Ontology;
|
use crate::rdf::ontology::Ontology;
|
||||||
|
|
||||||
fn main() -> color_eyre::Result<()> {
|
fn main() -> color_eyre::Result<()> {
|
||||||
@@ -50,52 +44,25 @@ fn main() -> color_eyre::Result<()> {
|
|||||||
let args = AppArgs::parse();
|
let args = AppArgs::parse();
|
||||||
match args.command {
|
match args.command {
|
||||||
Some(Command::Search(args)) => {
|
Some(Command::Search(args)) => {
|
||||||
for doc in index.query(args.discriminant, &args.query, Schema::all_fields(), 5)? {
|
for doc in index.query(args.discriminant, &args.query, Schema::all_fields(), 500000)? {
|
||||||
println!("{}", doc.to_json(Schema::schema()));
|
println!("{}", doc.to_json(Schema::schema()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Command::Reindex) => {
|
Some(Command::Reindex) => {
|
||||||
let curie_helper = CurieHelper::new(Ontology::prefixes().clone());
|
let mut writer = index.writer()?;
|
||||||
|
|
||||||
let writer = Arc::new(RwLock::new(index.writer()?));
|
|
||||||
debug_span!("Clear Index").in_scope(|| {
|
debug_span!("Clear Index").in_scope(|| {
|
||||||
let mut writer = writer.write()?;
|
|
||||||
writer.delete_all_documents()?;
|
writer.delete_all_documents()?;
|
||||||
writer.commit()
|
writer.commit()
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let store = ontology.store();
|
{
|
||||||
let writer_clone = writer.clone();
|
let span = debug_span!("Index Schema", documents = field::Empty).entered();
|
||||||
let index_classes_thread = thread::spawn(move || {
|
let store = ontology.store();
|
||||||
let span = debug_span!("Index Classes", documents = field::Empty).entered();
|
let count = gl_search::rdf::index_schema(store, &*gl_search::language::ENGLISH_OR_UNTAGGED, &writer)?;
|
||||||
let writer = writer_clone.read().unwrap();
|
|
||||||
let count = gl_search::rdf::index_triples(DocType::RdfsClass, store, &*gl_search::language::ENGLISH_OR_UNTAGGED, &*writer)?;
|
|
||||||
span.record("documents", count);
|
span.record("documents", count);
|
||||||
Ok::<(), gl_search::SearchError>(())
|
}
|
||||||
});
|
|
||||||
|
|
||||||
let store = ontology.store();
|
|
||||||
let writer_clone = writer.clone();
|
|
||||||
let index_properties_thread = thread::spawn(move || {
|
|
||||||
let span = debug_span!("Index Properties", documents = field::Empty).entered();
|
|
||||||
let writer = writer_clone.read().unwrap();
|
|
||||||
let count = gl_search::rdf::index_triples(DocType::RdfProperty, store, &*gl_search::language::ENGLISH_OR_UNTAGGED, &writer)?;
|
|
||||||
span.record("documents", count);
|
|
||||||
Ok::<(), gl_search::SearchError>(())
|
|
||||||
});
|
|
||||||
|
|
||||||
let store = ontology.store();
|
|
||||||
let writer_clone = writer.clone();
|
|
||||||
let index_concepts_thread = thread::spawn(move || {
|
|
||||||
let span = debug_span!("Index Concepts", documents = field::Empty).entered();
|
|
||||||
let writer = writer_clone.read().unwrap();
|
|
||||||
let count = gl_search::rdf::index_triples(DocType::SkosConcept, store, &*gl_search::language::ENGLISH_OR_UNTAGGED, &writer)?;
|
|
||||||
span.record("documents", count);
|
|
||||||
Ok::<(), gl_search::SearchError>(())
|
|
||||||
});
|
|
||||||
|
|
||||||
let starting_url = Url::parse("http://fedora.quill.lan/rest/")?;
|
let starting_url = Url::parse("http://fedora.quill.lan/rest/")?;
|
||||||
let writer_clone = writer.clone();
|
|
||||||
let runtime = tokio::runtime::Builder::new_multi_thread()
|
let runtime = tokio::runtime::Builder::new_multi_thread()
|
||||||
.enable_all()
|
.enable_all()
|
||||||
.name("repository-traversal")
|
.name("repository-traversal")
|
||||||
@@ -114,23 +81,17 @@ fn main() -> color_eyre::Result<()> {
|
|||||||
while let Some(result) = traversal.next().await {
|
while let Some(result) = traversal.next().await {
|
||||||
match result {
|
match result {
|
||||||
Ok(rdf_source) => {
|
Ok(rdf_source) => {
|
||||||
let writer = writer_clone.read().unwrap();
|
|
||||||
documents += gl_search::rdf::index_entity(rdf_source.dataset(), &*gl_search::language::ENGLISH_OR_UNTAGGED, &writer)?;
|
documents += gl_search::rdf::index_entity(rdf_source.dataset(), &*gl_search::language::ENGLISH_OR_UNTAGGED, &writer)?;
|
||||||
}
|
}
|
||||||
Err(err) => error!(?err),
|
Err(err) => error!(?err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug!(documents, "Repository Traversal");
|
debug!(documents, "Repository Traversal");
|
||||||
Ok::<(), gl_search::SearchError>(())
|
Ok::<_, gl_search::SearchError>(writer)
|
||||||
});
|
});
|
||||||
|
|
||||||
index_classes_thread.join().unwrap()?;
|
let mut writer = runtime.block_on(traversal_task)??;
|
||||||
index_properties_thread.join().unwrap()?;
|
|
||||||
index_concepts_thread.join().unwrap()?;
|
|
||||||
runtime.block_on(traversal_task)??;
|
|
||||||
|
|
||||||
debug_span!("Commit").in_scope(|| {
|
debug_span!("Commit").in_scope(|| {
|
||||||
let mut writer = writer.write()?;
|
|
||||||
writer.commit()
|
writer.commit()
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
use std::collections::BTreeMap;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct CurieHelper {
|
|
||||||
prefixes: BTreeMap<String, String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CurieHelper {
|
|
||||||
pub fn new(prefixes: BTreeMap<String, String>) -> Self {
|
|
||||||
Self {
|
|
||||||
prefixes,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn abbreviate(&self, base: Option<&str>, iri: &str) -> Option<String> {
|
|
||||||
if let Some(base) = base && let Some(local_name) = iri.strip_prefix(base) {
|
|
||||||
return Some(format!(":{local_name}"));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (name, base) in &self.prefixes {
|
|
||||||
if let Some(local_name) = iri.strip_prefix(base) {
|
|
||||||
return Some(format!("{name}:{local_name}"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn expand(&self, base: Option<&str>, abbreviated_iri: &str) -> Option<String> {
|
|
||||||
let (prefix, name) = abbreviated_iri.split_once(':')?;
|
|
||||||
|
|
||||||
if prefix == "" && let Some(base) = base {
|
|
||||||
Some(format!("{base}{name}"))
|
|
||||||
} else {
|
|
||||||
self.prefixes
|
|
||||||
.get(prefix)
|
|
||||||
.map(|base| format!("{base}{name}"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
|
use crate::error;
|
||||||
|
use gl_graph::vocab::owl;
|
||||||
use oxigraph::model::{Dataset, GraphName, NamedNodeRef, NamedOrBlankNode, NamedOrBlankNodeRef, Term};
|
use oxigraph::model::{Dataset, GraphName, NamedNodeRef, NamedOrBlankNode, NamedOrBlankNodeRef, Term};
|
||||||
use oxigraph::sparql::SparqlEvaluator;
|
use oxigraph::sparql::SparqlEvaluator;
|
||||||
use oxigraph::store::Store;
|
use oxigraph::store::Store;
|
||||||
use tracing::{debug, debug_span};
|
use tracing::{debug, debug_span};
|
||||||
use crate::error;
|
|
||||||
use crate::rdf::vocab::owl;
|
|
||||||
|
|
||||||
const INFERENCE_GRAPH: NamedNodeRef = NamedNodeRef::new_unchecked("https://graphofliberty.org/inference");
|
const INFERENCE_GRAPH: NamedNodeRef = NamedNodeRef::new_unchecked("https://graphofliberty.org/inference");
|
||||||
const RDF_SCHEMA: NamedNodeRef = NamedNodeRef::new_unchecked("http://www.w3.org/2000/01/rdf-schema#");
|
const RDF_SCHEMA: NamedNodeRef = NamedNodeRef::new_unchecked("http://www.w3.org/2000/01/rdf-schema#");
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
pub(crate) mod ontology;
|
pub(crate) mod ontology;
|
||||||
pub(crate) mod term_helper;
|
pub(crate) mod term_helper;
|
||||||
pub mod vocab;
|
|
||||||
pub(crate) mod materialize;
|
pub(crate) mod materialize;
|
||||||
pub(crate) mod conversion;
|
pub(crate) mod conversion;
|
||||||
pub(crate) mod curie;
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::error;
|
use crate::error;
|
||||||
use crate::rdf::vocab::gl;
|
|
||||||
use crate::rdf::{conversion, materialize};
|
use crate::rdf::{conversion, materialize};
|
||||||
|
use gl_graph::vocab::gl;
|
||||||
use gl_search::language::LanguageCondition;
|
use gl_search::language::LanguageCondition;
|
||||||
use iced::futures::TryFutureExt;
|
use iced::futures::TryFutureExt;
|
||||||
use oxigraph::model::vocab::{rdf, rdfs, xsd};
|
use oxigraph::model::vocab::{rdf, rdfs, xsd};
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
pub mod gl {
|
|
||||||
use oxigraph::model::NamedNodeRef;
|
|
||||||
|
|
||||||
pub const TEMPLATE: NamedNodeRef =
|
|
||||||
NamedNodeRef::new_unchecked("https://graphofliberty.org/2026/04/ont/template");
|
|
||||||
|
|
||||||
pub const INDEXED_BY_FIELD: NamedNodeRef =
|
|
||||||
NamedNodeRef::new_unchecked("https://graphofliberty.org/2026/04/ont/indexedByField");
|
|
||||||
|
|
||||||
pub const CATEGORY_ID: NamedNodeRef =
|
|
||||||
NamedNodeRef::new_unchecked("https://graphofliberty.org/2026/04/ont/categoryId");
|
|
||||||
|
|
||||||
pub const SEARCHABLE_CLASS: NamedNodeRef =
|
|
||||||
NamedNodeRef::new_unchecked("https://graphofliberty.org/2026/04/ont/SearchableClass");
|
|
||||||
|
|
||||||
pub const ENTITY: NamedNodeRef =
|
|
||||||
NamedNodeRef::new_unchecked("https://graphofliberty.org/2026/04/ont/Entity");
|
|
||||||
|
|
||||||
pub const ASSOCIATED_PROPERTY: NamedNodeRef =
|
|
||||||
NamedNodeRef::new_unchecked("https://graphofliberty.org/2026/04/ont/associatedProperty");
|
|
||||||
|
|
||||||
pub const READ_ONLY: NamedNodeRef =
|
|
||||||
NamedNodeRef::new_unchecked("https://graphofliberty.org/2026/04/ont/readOnly");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub mod owl {
|
|
||||||
use oxigraph::model::NamedNodeRef;
|
|
||||||
|
|
||||||
pub const SAME_AS: NamedNodeRef =
|
|
||||||
NamedNodeRef::new_unchecked("http://www.w3.org/2002/07/owl#sameAs");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub mod rda {
|
|
||||||
use oxigraph::model::NamedNodeRef;
|
|
||||||
|
|
||||||
pub const ENTITY: NamedNodeRef =
|
|
||||||
NamedNodeRef::new_unchecked("http://rdaregistry.info/Elements/c/C10013");
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
use iced::{alignment, keyboard, widget, Element, Event, Length, Rectangle, Size};
|
use iced::{keyboard, widget, Element, Event, Length, Rectangle, Size};
|
||||||
use iced::advanced::{mouse, text, Shell, renderer};
|
use iced::advanced::{mouse, text, Shell, renderer};
|
||||||
use iced::advanced::layout::{Limits, Node};
|
use iced::advanced::layout::{Limits, Node};
|
||||||
use iced::advanced::{Layout, Widget};
|
use iced::advanced::{Layout, Widget};
|
||||||
@@ -6,7 +6,7 @@ use iced::advanced::widget::{tree, Tree, Operation};
|
|||||||
use iced::clipboard::Content;
|
use iced::clipboard::Content;
|
||||||
use iced::mouse::{Cursor, Interaction};
|
use iced::mouse::{Cursor, Interaction};
|
||||||
use iced::widget::text_input::{Catalog, Status, Style, StyleFn};
|
use iced::widget::text_input::{Catalog, Status, Style, StyleFn};
|
||||||
use crate::rdf::curie::CurieHelper;
|
use gl_graph::CurieHelper;
|
||||||
|
|
||||||
pub struct State {
|
pub struct State {
|
||||||
control: bool,
|
control: bool,
|
||||||
|
|||||||
+2
-1
@@ -5,10 +5,11 @@ edition = "2024"
|
|||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
gl-graph.workspace = true
|
||||||
|
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
tantivy.workspace = true
|
tantivy.workspace = true
|
||||||
thiserror.workspace = true
|
thiserror.workspace = true
|
||||||
|
|
||||||
#poppler-rs = "0.26.0-alpha.0"
|
#poppler-rs = "0.26.0-alpha.0"
|
||||||
subtitler.workspace = true
|
subtitler.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
|
|||||||
@@ -23,7 +23,4 @@ pub enum SearchError {
|
|||||||
|
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
SparqlSyntax(#[from] oxigraph::sparql::SparqlSyntaxError),
|
SparqlSyntax(#[from] oxigraph::sparql::SparqlSyntaxError),
|
||||||
|
|
||||||
#[error("The provided DocType is not valid for this operation")]
|
|
||||||
InvalidDocType,
|
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-3
@@ -12,6 +12,7 @@ pub use tantivy::schema::document::{Document, Value};
|
|||||||
pub use tantivy::indexer::IndexWriter;
|
pub use tantivy::indexer::IndexWriter;
|
||||||
|
|
||||||
pub use error::{Result, SearchError};
|
pub use error::{Result, SearchError};
|
||||||
|
use gl_graph::vocab;
|
||||||
pub use index::{SearchIndex, SearchIndexBuilder};
|
pub use index::{SearchIndex, SearchIndexBuilder};
|
||||||
pub use schema::Schema;
|
pub use schema::Schema;
|
||||||
|
|
||||||
@@ -20,12 +21,37 @@ pub enum DocType {
|
|||||||
RdfsClass = 1,
|
RdfsClass = 1,
|
||||||
SkosConcept = 2,
|
SkosConcept = 2,
|
||||||
Person = 3,
|
Person = 3,
|
||||||
|
CorporateBody = 4,
|
||||||
|
Work = 5,
|
||||||
|
Expression = 6,
|
||||||
|
Manifestation = 7,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DocType {
|
impl DocType {
|
||||||
pub fn from_named_node(node: NamedNodeRef) -> Option<Self> {
|
pub fn to_named_node(&self) -> NamedNodeRef<'_> {
|
||||||
match node.as_str() {
|
match self {
|
||||||
"http://rdaregistry.info/Elements/c/C10004" => Some(DocType::Person),
|
DocType::RdfProperty => vocab::rdf::PROPERTY,
|
||||||
|
DocType::RdfsClass => vocab::rdfs::CLASS,
|
||||||
|
DocType::SkosConcept => vocab::skos::CONCEPT,
|
||||||
|
DocType::Person => vocab::rdac::PERSON,
|
||||||
|
DocType::CorporateBody => vocab::rdac::CORPORATE_BODY,
|
||||||
|
DocType::Work => vocab::rdac::WORK,
|
||||||
|
DocType::Expression => vocab::rdac::EXPRESSION,
|
||||||
|
DocType::Manifestation => vocab::rdac::MANIFESTATION,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from_named_node<'a>(node: impl Into<NamedNodeRef<'a>>) -> Option<Self> {
|
||||||
|
let node = node.into();
|
||||||
|
match node {
|
||||||
|
vocab::rdf::PROPERTY => Some(DocType::RdfProperty),
|
||||||
|
vocab::rdfs::CLASS => Some(DocType::RdfsClass),
|
||||||
|
vocab::skos::CONCEPT => Some(DocType::SkosConcept),
|
||||||
|
vocab::rdac::PERSON => Some(DocType::Person),
|
||||||
|
vocab::rdac::CORPORATE_BODY => Some(DocType::CorporateBody),
|
||||||
|
vocab::rdac::WORK => Some(DocType::Work),
|
||||||
|
vocab::rdac::EXPRESSION => Some(DocType::Expression),
|
||||||
|
vocab::rdac::MANIFESTATION => Some(DocType::Manifestation),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+68
-33
@@ -5,10 +5,11 @@ use oxigraph::sparql::{QueryResults, SparqlEvaluator};
|
|||||||
use oxigraph::store::Store;
|
use oxigraph::store::Store;
|
||||||
use tantivy::IndexWriter;
|
use tantivy::IndexWriter;
|
||||||
use tantivy::schema::{Field, OwnedValue};
|
use tantivy::schema::{Field, OwnedValue};
|
||||||
|
use tracing::debug;
|
||||||
|
use gl_graph::{vocab, CurieHelper};
|
||||||
use crate::DocType;
|
use crate::DocType;
|
||||||
use crate::language::LanguageCondition;
|
use crate::language::LanguageCondition;
|
||||||
use crate::schema::Schema;
|
use crate::schema::Schema;
|
||||||
use crate::SearchError::InvalidDocType;
|
|
||||||
|
|
||||||
fn term_to_named_node(term: &Term) -> Option<&NamedNode> {
|
fn term_to_named_node(term: &Term) -> Option<&NamedNode> {
|
||||||
if let Term::NamedNode(node) = term {
|
if let Term::NamedNode(node) = term {
|
||||||
@@ -52,16 +53,15 @@ fn term_ref_as_str(term: TermRef<'_>) -> Option<&str> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const GIVEN_NAME: NamedNodeRef = NamedNodeRef::new_unchecked("http://rdaregistry.info/Elements/a/datatype/P50292");
|
|
||||||
const SURNAME: NamedNodeRef = NamedNodeRef::new_unchecked("http://rdaregistry.info/Elements/a/datatype/P50291");
|
|
||||||
|
|
||||||
pub fn index_entity(dataset: &Dataset, language: &LanguageCondition, writer: &IndexWriter<HashMap<Field, OwnedValue>>) -> crate::Result<usize> {
|
pub fn index_entity(dataset: &Dataset, language: &LanguageCondition, writer: &IndexWriter<HashMap<Field, OwnedValue>>) -> crate::Result<usize> {
|
||||||
|
let curie_helper = CurieHelper::new((&*gl_graph::PREFIXES).clone());
|
||||||
|
|
||||||
let mut subject_type_map = HashMap::new();
|
let mut subject_type_map = HashMap::new();
|
||||||
for quad in dataset.quads_for_pattern(None, Some(rdf::TYPE), None, None) {
|
for quad in dataset.quads_for_pattern(None, Some(rdf::TYPE), None, None) {
|
||||||
if let NamedOrBlankNodeRef::NamedNode(subject) = quad.subject {
|
if let NamedOrBlankNodeRef::NamedNode(subject) = quad.subject {
|
||||||
subject_type_map.entry(subject)
|
subject_type_map.entry(subject)
|
||||||
.and_modify(|types: &mut Vec<_>| types.push(quad.object))
|
.and_modify(|types: &mut Vec<_>| types.push(quad.object))
|
||||||
.or_insert_with(Vec::new);
|
.or_insert_with(|| vec![quad.object]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,16 +69,24 @@ pub fn index_entity(dataset: &Dataset, language: &LanguageCondition, writer: &In
|
|||||||
for (subject, types) in subject_type_map {
|
for (subject, types) in subject_type_map {
|
||||||
for type_ in types {
|
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::from_named_node) {
|
||||||
match doc_type {
|
let mut doc = match doc_type {
|
||||||
DocType::Person => {
|
DocType::Person => index_person(dataset, subject, language),
|
||||||
let mut doc = index_person(dataset, subject, language);
|
DocType::CorporateBody => index_corporate_body(dataset, subject, language),
|
||||||
doc.insert(Schema::discriminant_field(), OwnedValue::U64(doc_type as u64));
|
_ => continue
|
||||||
doc.insert(Schema::iri_field(), OwnedValue::Str(subject.as_str().to_string()));
|
};
|
||||||
writer.add_document(doc)?;
|
|
||||||
counter += 1;
|
let subject_str = subject.as_str();
|
||||||
}
|
|
||||||
_ => {}
|
doc.insert(Schema::discriminant_field(), OwnedValue::U64(doc_type as u64));
|
||||||
}
|
doc.insert(Schema::iri_field(), OwnedValue::Str(subject_str.to_string()));
|
||||||
|
|
||||||
|
let curie = curie_helper.abbreviate(None, subject_str)
|
||||||
|
.map(OwnedValue::Str)
|
||||||
|
.unwrap_or(OwnedValue::Null);
|
||||||
|
doc.insert(Schema::curie_field(), curie);
|
||||||
|
|
||||||
|
writer.add_document(doc)?;
|
||||||
|
counter += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,7 +95,7 @@ pub fn index_entity(dataset: &Dataset, language: &LanguageCondition, writer: &In
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn index_person(dataset: &Dataset, subject: NamedNodeRef<'_>, language: &LanguageCondition) -> HashMap<Field, OwnedValue> {
|
fn index_person(dataset: &Dataset, subject: NamedNodeRef<'_>, language: &LanguageCondition) -> HashMap<Field, OwnedValue> {
|
||||||
let given_name = dataset.quads_for_pattern(Some(subject.into()), Some(GIVEN_NAME), None, None)
|
let given_name = dataset.quads_for_pattern(Some(subject.into()), Some(vocab::rdaad::GIVEN_NAME), None, None)
|
||||||
.map(|q| q.object)
|
.map(|q| q.object)
|
||||||
.filter(|term| language.primary_matches_term(*term))
|
.filter(|term| language.primary_matches_term(*term))
|
||||||
.filter_map(term_ref_as_str)
|
.filter_map(term_ref_as_str)
|
||||||
@@ -96,7 +104,7 @@ fn index_person(dataset: &Dataset, subject: NamedNodeRef<'_>, language: &Languag
|
|||||||
.next()
|
.next()
|
||||||
.unwrap_or_else(|| OwnedValue::Null);
|
.unwrap_or_else(|| OwnedValue::Null);
|
||||||
|
|
||||||
let surname = dataset.quads_for_pattern(Some(subject.into()), Some(SURNAME), None, None)
|
let surname = dataset.quads_for_pattern(Some(subject.into()), Some(vocab::rdaad::SURNAME), None, None)
|
||||||
.map(|q| q.object)
|
.map(|q| q.object)
|
||||||
.filter(|term| language.primary_matches_term(*term))
|
.filter(|term| language.primary_matches_term(*term))
|
||||||
.filter_map(term_ref_as_str)
|
.filter_map(term_ref_as_str)
|
||||||
@@ -111,18 +119,30 @@ fn index_person(dataset: &Dataset, subject: NamedNodeRef<'_>, language: &Languag
|
|||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn index_triples(doc_type: DocType, store: Store, language: &LanguageCondition, writer: &IndexWriter<HashMap<Field, OwnedValue>>) -> crate::Result<usize> {
|
fn index_corporate_body(dataset: &Dataset, subject: NamedNodeRef<'_>, language: &LanguageCondition) -> HashMap<Field, OwnedValue> {
|
||||||
|
let name = dataset.quads_for_pattern(Some(subject.into()), Some(vocab::rdaad::NAME_OF_CORPORATE_BODY), None, None)
|
||||||
|
.map(|q| q.object)
|
||||||
|
.filter(|term| language.primary_matches_term(*term))
|
||||||
|
.filter_map(term_ref_as_str)
|
||||||
|
.map(String::from)
|
||||||
|
.map(OwnedValue::Str)
|
||||||
|
.next()
|
||||||
|
.unwrap_or_else(|| OwnedValue::Null);
|
||||||
|
|
||||||
|
HashMap::from_iter([
|
||||||
|
(Schema::field("corporate_name", language.primary_language()), name),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn index_schema(store: Store, language: &LanguageCondition, writer: &IndexWriter<HashMap<Field, OwnedValue>>) -> crate::Result<usize> {
|
||||||
|
let curie_helper = CurieHelper::new((&*gl_graph::PREFIXES).clone());
|
||||||
|
|
||||||
let label_filter = language.to_filter_expression("label");
|
let label_filter = language.to_filter_expression("label");
|
||||||
let description_filter = language.to_filter_expression("description");
|
let description_filter = language.to_filter_expression("description");
|
||||||
let rdf_type = match doc_type {
|
|
||||||
DocType::RdfsClass => Ok("rdfs:Class"),
|
|
||||||
DocType::RdfProperty => Ok("rdf:Property"),
|
|
||||||
DocType::SkosConcept => Ok("skos:Concept"),
|
|
||||||
_ => Err(InvalidDocType),
|
|
||||||
}?;
|
|
||||||
|
|
||||||
let query = format!(r#"SELECT ?subject ?label ?description WHERE {{
|
let query = format!(r#"SELECT ?class ?subject ?label ?description WHERE {{
|
||||||
?subject a {rdf_type} ;
|
VALUES ?class {{ rdf:Property rdfs:Class skos:Concept }}
|
||||||
|
?subject a ?class ;
|
||||||
rdfs:label ?label .
|
rdfs:label ?label .
|
||||||
{label_filter}
|
{label_filter}
|
||||||
|
|
||||||
@@ -141,17 +161,32 @@ pub fn index_triples(doc_type: DocType, store: Store, language: &LanguageConditi
|
|||||||
let mut counter = 0usize;
|
let mut counter = 0usize;
|
||||||
let query_results = sparql.on_store(&store).execute()?;
|
let query_results = sparql.on_store(&store).execute()?;
|
||||||
if let QueryResults::Solutions(solutions) = query_results {
|
if let QueryResults::Solutions(solutions) = query_results {
|
||||||
let discriminant = OwnedValue::U64(doc_type as u64);
|
|
||||||
let primary_language = language.primary_language();
|
let primary_language = language.primary_language();
|
||||||
|
let label_field = Schema::field("label", primary_language);
|
||||||
|
let definition_field = Schema::field("definition", primary_language);
|
||||||
|
|
||||||
for solution in solutions.filter_map(Result::ok) {
|
for solution in solutions.filter_map(Result::ok) {
|
||||||
let mut document = HashMap::with_capacity(4);
|
let mut document = HashMap::with_capacity(4);
|
||||||
document.insert(Schema::discriminant_field(), discriminant.clone());
|
|
||||||
|
|
||||||
let subject = solution.get("subject")
|
let discriminant = solution.get("class")
|
||||||
.and_then(term_to_named_node)
|
.and_then(term_to_named_node)
|
||||||
.map(NamedNode::as_str)
|
.and_then(DocType::from_named_node)
|
||||||
.map(OwnedValue::from)
|
.map(|doc_type| doc_type as u64)
|
||||||
|
.map(OwnedValue::U64)
|
||||||
|
.unwrap_or(OwnedValue::Null);
|
||||||
|
document.insert(Schema::discriminant_field(), discriminant);
|
||||||
|
|
||||||
|
let subject_str = solution.get("subject")
|
||||||
|
.and_then(term_to_named_node)
|
||||||
|
.map(NamedNode::as_str);
|
||||||
|
|
||||||
|
let curie = subject_str
|
||||||
|
.and_then(|subject| curie_helper.abbreviate(None, subject))
|
||||||
|
.map(OwnedValue::Str)
|
||||||
|
.unwrap_or(OwnedValue::Null);
|
||||||
|
document.insert(Schema::curie_field(), curie);
|
||||||
|
|
||||||
|
let subject = subject_str.map(OwnedValue::from)
|
||||||
.unwrap_or(OwnedValue::Null);
|
.unwrap_or(OwnedValue::Null);
|
||||||
document.insert(Schema::iri_field(), subject);
|
document.insert(Schema::iri_field(), subject);
|
||||||
|
|
||||||
@@ -159,13 +194,13 @@ pub fn index_triples(doc_type: DocType, store: Store, language: &LanguageConditi
|
|||||||
.and_then(term_as_str)
|
.and_then(term_as_str)
|
||||||
.map(OwnedValue::from)
|
.map(OwnedValue::from)
|
||||||
.unwrap_or(OwnedValue::Null);
|
.unwrap_or(OwnedValue::Null);
|
||||||
document.insert(Schema::field("label", primary_language), label);
|
document.insert(label_field, label);
|
||||||
|
|
||||||
let definition = solution.get("description")
|
let definition = solution.get("description")
|
||||||
.and_then(term_as_str)
|
.and_then(term_as_str)
|
||||||
.map(OwnedValue::from)
|
.map(OwnedValue::from)
|
||||||
.unwrap_or(OwnedValue::Null);
|
.unwrap_or(OwnedValue::Null);
|
||||||
document.insert(Schema::field("definition", primary_language), definition);
|
document.insert(definition_field, definition);
|
||||||
|
|
||||||
writer.add_document(document)?;
|
writer.add_document(document)?;
|
||||||
counter += 1;
|
counter += 1;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ impl Schema {
|
|||||||
|
|
||||||
schema_builder.add_text_field("surname:en", stored_ngram32.clone());
|
schema_builder.add_text_field("surname:en", stored_ngram32.clone());
|
||||||
schema_builder.add_text_field("given_name:en", stored_ngram32.clone());
|
schema_builder.add_text_field("given_name:en", stored_ngram32.clone());
|
||||||
|
schema_builder.add_text_field("corporate_name:en", stored_ngram32.clone());
|
||||||
|
|
||||||
schema_builder.add_u64_field("subtitle_start", schema::STORED);
|
schema_builder.add_u64_field("subtitle_start", schema::STORED);
|
||||||
schema_builder.add_u64_field("subtitle_end", schema::STORED);
|
schema_builder.add_u64_field("subtitle_end", schema::STORED);
|
||||||
|
|||||||
Reference in New Issue
Block a user