.
This commit is contained in:
+19
-6
@@ -1,7 +1,7 @@
|
||||
use crate::rdf::ontology;
|
||||
use crate::rdf::ontology::Ontology;
|
||||
use crate::rdf::term_helper::{TermHelper, TermHelperMut};
|
||||
use gl_search::{Schema, SearchDocument, SearchIndex};
|
||||
use gl_search::{doc, Schema, SearchDocument, SearchIndex};
|
||||
use http::StatusCode;
|
||||
use iced::alignment::Horizontal;
|
||||
use iced::widget::button::Style;
|
||||
@@ -23,6 +23,8 @@ use oxigraph::model::vocab::rdf;
|
||||
use oxigraph::model::{BaseDirection, Dataset, NamedNode, Quad, Term, TermRef};
|
||||
use tracing::{debug, error};
|
||||
|
||||
const ANNOTATED_IRI_TYPE: u64 = 0;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) enum Message {
|
||||
None,
|
||||
@@ -104,11 +106,22 @@ impl Publisher {
|
||||
.build()
|
||||
.expect("Failed to build search index");
|
||||
|
||||
index.remove_all_annotated_iris();
|
||||
index.remove_all_of_type(ANNOTATED_IRI_TYPE);
|
||||
ontology.for_each_annotated_iri(|iri, label, comment| {
|
||||
index
|
||||
.add_annotated_iri(iri, label, comment)
|
||||
.expect("Unable to add annotated IRI to search index");
|
||||
let mut document = doc!(
|
||||
Schema::type_field() => ANNOTATED_IRI_TYPE,
|
||||
Schema::iri_field() => iri,
|
||||
);
|
||||
|
||||
if let Some(label) = label {
|
||||
document.add_text(Schema::field("label"), label.to_lowercase());
|
||||
}
|
||||
|
||||
if let Some(comment) = comment {
|
||||
document.add_text(Schema::field("comment"), comment.to_lowercase());
|
||||
}
|
||||
|
||||
index.add(document).expect("Unable to add annotated IRI to search index");
|
||||
});
|
||||
index.commit().expect("Unable to commit ontology to index");
|
||||
|
||||
@@ -309,7 +322,7 @@ impl Publisher {
|
||||
if let Some(search_state) = &mut self.search_state {
|
||||
search_state.results = self
|
||||
.index
|
||||
.query(7, new_query.as_str(), Schema::default_fields())
|
||||
.query(0, new_query.as_str(), Schema::all_fields())
|
||||
.expect("Error encountered while querying index")
|
||||
.iter()
|
||||
.map(NamedNode::new_unchecked)
|
||||
|
||||
Reference in New Issue
Block a user