This PR adds supports for approximate string matching using full text search queries. It follows an approach similar to BlazeGraph and defines several magic predicates that are given special meaning, and when encountered in a SPARQL query, they are interpreted as configuration parameters for a full text search query.
The simplest way to integrate a full text search into a SPARQL query is to use the magic predicate ses:search inside of a SPARQL join group. In the following query, this predicate is used to search for the keywords neil and gaiman in the values binded to the ?o position of the triple pattern.
In a way, full text search queries allows users to express more complex SPARQL filters that performs approximate string matching over RDF terms.
Each result is annotated with a relevance score (how much it matches the keywords, higher is better) and a rank (they represent the descending order of relevance scores). These two values are not binded by default into the query results, but you can use magic predicates to get access to them (see below). Note that the meaning of relevance scores is specific to the implementation of the full text search.
The full list of magic predicates that you can use in a full text search query is:
ses:search defines keywords to search as a list of keywords separated by spaces.
ses:matchAllTerms indicates that only values that contain all of the specified search terms should be considered.
ses:minRelevanceand ses:maxRelevance limits the search to matches with a minimum/maximum
relevance score, respectively. In the default implementation, scores are floating numbers, ranging from 0.0 to 1.0 with a precision of 4 digits.
ses:minRank and ses:maxRank limits the search to matches with a minimum/maximum
rank value, respectively. In the default implementation, ranks are positive integers starting at 0.
ses:relevance binds each term's relevance score to a SPARQL variable.
ses:rank binds each term's rank to a SPARQL variable.
Below is a more complete example, that use most of these keywords to customize the full text search.
This PR adds supports for approximate string matching using full text search queries. It follows an approach similar to BlazeGraph and defines several magic predicates that are given special meaning, and when encountered in a SPARQL query, they are interpreted as configuration parameters for a full text search query.
The simplest way to integrate a full text search into a SPARQL query is to use the magic predicate
ses:search
inside of a SPARQL join group. In the following query, this predicate is used to search for the keywordsneil
andgaiman
in the values binded to the?o
position of the triple pattern.In a way, full text search queries allows users to express more complex SPARQL filters that performs approximate string matching over RDF terms. Each result is annotated with a relevance score (how much it matches the keywords, higher is better) and a rank (they represent the descending order of relevance scores). These two values are not binded by default into the query results, but you can use magic predicates to get access to them (see below). Note that the meaning of relevance scores is specific to the implementation of the full text search.
The full list of magic predicates that you can use in a full text search query is:
ses:search
defines keywords to search as a list of keywords separated by spaces.ses:matchAllTerms
indicates that only values that contain all of the specified search terms should be considered.ses:minRelevance
andses:maxRelevance
limits the search to matches with a minimum/maximum relevance score, respectively. In the default implementation, scores are floating numbers, ranging from 0.0 to 1.0 with a precision of 4 digits.ses:minRank
andses:maxRank
limits the search to matches with a minimum/maximum rank value, respectively. In the default implementation, ranks are positive integers starting at 0.ses:relevance
binds each term's relevance score to a SPARQL variable.ses:rank
binds each term's rank to a SPARQL variable.Below is a more complete example, that use most of these keywords to customize the full text search.