Search Strategy

The Purpose

Semantic Turkey supports full-text search over the literal content of the managed RDF knowledge base. Furthermore, it should exploit whenever available the optimized search capabilities offered by the underlying RDF triple store. In order to support different triple store technologies, the required capabilities are decoupled from the underlying implementation by means of the extension point SearchStrategy.

The Model

A SearchStrategy (it.uniroma2.art.semanticturkey.extension.extpts.search.SearchStrategy) implements a number of full-text search primitives required by Semantic Turkey using mechanisms provided by a specific RDF technology.

Extension Point Details

The tables below summarizes the details of the Search Strategy extension point.

Name Search Strategy
Description An Search Strategy implements the full-text search primitives required by Semantic Turkey using capabilities offered by a specific RDF technology.
Identifier it.uniroma2.art.semanticturkey.extension.extpts.search.SearchStrategy
Configuration n/a
Settings n/a

Interfaces

The following interface defines the contract for the SearchStrategy extension point.


/**
* Common interface abstracting different search mechanisms.
*/
public interface SearchStrategy extends Extension {

	public enum StatusFilter {
		NOT_DEPRECATED, ONLY_DEPRECATED, UNDER_VALIDATION, UNDER_VALIDATION_FOR_DEPRECATION, ANYTHING
	}

	/**
	* Performs initialization steps, such as the creation of indexes. It may be a no-op method, if no
	* specific initialization is required.
	*/
	void initialize(RepositoryConnection connection) throws Exception;

	/**
	* Updates support resources (usually created inside {@link SearchStrategy#initialize(Project)}).
	*/
	void update(RepositoryConnection connection) throws Exception;

	String searchResource(STServiceContext stServiceContext, String searchString, String[] rolesArray,
			boolean useLocalName, boolean useURI, boolean useNotes, SearchMode searchMode,
			@Nullable List<IRI> schemes, @Nullable List<String> langs, boolean includeLocales, IRI lexModel,
			boolean searchInRDFSLabel, boolean searchInSKOSLabel, boolean searchInSKOSXLLabel,
			boolean searchInOntolex) throws IllegalStateException, STPropertyAccessException;

	Collection<String> searchStringList(STServiceContext stServiceContext, String searchString,
			@Optional String[] rolesArray, boolean useLocalName, SearchMode searchMode,
			@Nullable List<IRI> schemes, @Nullable List<String> langs, @Nullable IRI cls,
			boolean includeLocales) throws IllegalStateException, STPropertyAccessException;

	Collection<String> searchURIList(STServiceContext stServiceContext, String searchString,
			@Optional String[] rolesArray, SearchMode searchMode, @Nullable List<IRI> schemes,
			@Nullable IRI cls) throws IllegalStateException, STPropertyAccessException;

	String searchInstancesOfClass(STServiceContext stServiceContext, List<List<IRI>> clsListList,
			String searchString, boolean useLocalName, boolean useURI, boolean useNotes,
			SearchMode searchMode, @Nullable List<String> langs, boolean includeLocales,
			boolean searchStringCanBeNull, boolean searchInSubTypes, IRI lexModel, boolean searchInRDFSLabel,
			boolean searchInSKOSLabel, boolean searchInSKOSXLLabel, boolean searchInOntolex,
			@Nullable List<List<IRI>> schemes, StatusFilter statusFilter,
			@Nullable List<Pair<IRI, List<Value>>> outgoingLinks,
			@Nullable List<TripleForSearch<IRI, String, SearchMode>> outgoingSearch,
			@JsonSerialized List<Pair<IRI, List<Value>>> ingoingLinks, SearchStrategy searchStrategy,
			String baseURI) throws IllegalStateException, STPropertyAccessException;

	public String searchSpecificModePrepareQuery(String variable, String value, SearchMode searchMode,
			String indexToUse, List<String> langs, boolean includeLocales, boolean forLocalName);

	String searchLexicalEntry(STServiceContext stServiceContext, String searchString, boolean useLocalName,
			boolean useURI, boolean useNotes, SearchMode searchMode, List<IRI> lexicons, List<String> langs,
			boolean includeLocales, IRI iri, boolean searchInRDFSLabel, boolean searchInSKOSLabel,
			boolean searchInSKOSXLLabel, boolean searchInOntolex)
			throws IllegalStateException, STPropertyAccessException;
}			

Choosing and Configuring a Search Strategy

Upon project creation, the backend type is used to configure inside the file repositories-info.json which search strategy to use. Similarly, when an additional repository is configured for a project, the compatible search strategy is recorded as well in the same file. Currently, the search strategy is identified via an enumeration (REGEX or GRAPH_DB) corresponding to known predefined implementations of this extension point.

Search Strategy Implementations

GraphDB Search Strategy

Name GraphDB Search Strategy
Description A SearchStrategy utilizing the full-text search capabilities offered by Ontotext GraphDB (based on Apache Lucene).
Identifier it.uniroma2.art.semanticturkey.extension.impl.search.graphdb.GraphDBSearchStrategy
Configuration n/a
Settings n/a

Regex Search Strategy

Name Regex Search Strategy
Description A SearchStrategy that uses regular expressions inside SPARQL queries. This implementation is compatible with a variety of triple stores, but suffers from low performances on large RDF datasets.
Identifier it.uniroma2.art.semanticturkey.extension.impl.search.regex.RegexSearchStrategy
Configuration n/a
Settings n/a