Link an ontology

Valid from Datafari v4.0

Datafari gives you the opportunity to link an ontology to it, in order to enrich your documents with the ontology data and then use these additional infos in the search phase.

To do so, the first step is to add the OntologyUpdateProcessor as a custom UpdateProcessor in the file {Datafari_Home}/solr/solr_home/FileShare/conf/customs_solrconfig/custom_update_processors.xml

The OntologyUpdateProcessor will index, for each document inserted in Solr, the labels of the corresponding node into the specified ontology but also its parents and children labels and URIs.
It has several parameters that can be set:

  • enabled : boolean value to enable/disable the OntologyUpdateProcessor

  • annotationField[REQUIRED] the field in the input document that contains the annotation URI used as the reference in the ontology.

Note that this field must be added to the document by yourself: Datafari does not provide any plugin or other mechanism to do it. You may want to modify the DatafariUpdateProcessor or make your own UpdateProcessor to do so.

  • ontologyURI[REQUIRED] the location of the ontology, such as http://francelabs.com/ontology/owl.rdf or file:///ontology/owl.rdf

Datafari only supports OWL ontology format for now, so the ontologyURI parameter has to reference a OWL formated ontology

  • labelField : the field in your schema that should be used for the annotation's label(s). Default: ontology_labels

  • childField : the field to be used for child document references. These are direct (ie. single-step) relationships down the hierarchy. Default: ontology_children

  • parentField : the field to be used for parent document references. These are direct relationships up the hierarchy. Default: ontology_parents

  • childLabel : the field to be used for child documents labels. Default: ontology_children_labels

  • parentLabel : the field to be used for parent documents labels. Default: ontology_parents_labels

  • useLanguages : (boolean) should language distinction for label fields be used ? If this is set to true, the processor will create additional label fields for each language found, using the language as a suffix, for instance  ontology_parents_labels_fr, ontology_parents_labels_en
    The field format is [Original_Label_Field]_[Language]
    This is useful if you want to have, in addition to the original label fields which will contain all values, specific label fields containing values of the concerned language. But remember that the more the Ontology contains languages, the more it will create label fields.
    Default: false

  • includeIndirect : (boolean) should indirect parent/child relationships also be indexed ? If this is set to true, all ancestor and descendant labels and URIs will also be added to the document. Default: false.

  • descendantsField : the field to be used for the full set of descendant references. These are direct AND indirect relationships down the hierarchy. Default: ontology_descendants

  • ancestorsField : the field to be used for the full set of ancestor references. These are direct AND indirect relationships up the hierarchy. Default: ontology_ancestors

  • descendantsLabel : the field to be used for descendant documents labels. Default: ontology_descendants_labels

  • ancestorsLabel : the field to be used for ancestor documents labels. Default: ontology_ancestors_labels

To implement the OntologyUpdateProcessor, follow these steps:

  • open the 'custom_libs.xml' file in {Datafari_installation_folder}/solr/solr_home/FileShare/conf/customs_solrconfig/

  • add the following line (replace the '<to_remove_tag>') :

    <lib dir="./lib/jena"/>
  • open the 'custom_update_processors.xml' file in the same location

  • add the following lines(still replace the '<to_remove_tag>'):

    <processor class="com.francelabs.datafari.updateprocessor.OntologyUpdateProcessorFactory"> <bool name="enabled">true</bool> <str name="annotationField">ontology_annotation</str> <!-- Location of the ontology --> <str name="ontologyURI">file:///owl.rdf</str> </processor>
  • Restart Datafari

  • Crawl (again) your documents to add to them the new fields generated by the OntologyUpdateProcessor

Then, you can configure Datafari to use the new Ontology infos on the search requests :

  • open the 'datafari.properties' file in {Datafari_installation_folder}/tomcat/conf/

  • Modify those lines to set the ontologyEnabled property to true and the other lines to match with your ontology configuration:

    ontologyEnabled=true ontologyLanguageSelection=true ontologyNodeLabels=ontology_labels ontologyChildrenLabels=ontology_children_labels ontologyParentsLabels=ontology_parents_labels

    ontologyEnabled : (boolean) Enable or disable the ontology use
    ontologyLanguageSelection : (boolean) should use the Datafari selected language for the ontology labels ? If true, be sure that you used the OntologyUpdateProcessor with the parameter userLanguages set to true during the crawl of the documents by MCF
    ontologyNodeLabels : the field in your schema that contains the annotation's label(s)
    ontologyChildrenLabels : the field in your schema that contains the child documents labels
    ontologyParentsLabels : the field in your schema that contains the parent documents labels

Your Datafari is now ready to use the ontology additional fields during search queries thanks to the OntologySuggestion.widget