Sometimes you want to find something in your graph without writing a SPARQL query, and now Studio is here to help.

Background

SPARQL is an extremely powerful query language and RDF’s schema-as-data foundation makes everything in your knowledge graph accessible with a SPARQL query.

However, until you are fluent in SPARQL, the friction of writing a query can be too much. We are working hard to make writing SPARQL queries easier by investing in the editor experience with features such as language intelligence, code folding and syntax highlighting. But we are also working to give users a head-start.

Moreover, Stardog embeds functionality in SPARQL such as fulltext search, entity extraction, geospatial queries, and machine learning. Doing so makes this functionality convenient to use, but hard to find, as no special API is needed. To begin addressing this we added Studio’s first query shortcut to help users discover Stardog’s rich fulltext search support.

Search Shortcut

Studio 1.13 adds a search shortcut to Studio’s Editor section. Clicking the magnifying glass icon displays a search field where you can type your search term. Hit ‘Enter’ to open a new tab with your search results and the query we built to get them.

Once you have executed a search you probably want to refine it. To do so we added several tips to your SPARQL query:

  1. Restrict results to the three most common rdf:type values. We pre-populate and comment out a VALUES statement which, when added to your query, will restrict your results to nodes with any of the specified type(s). The statement includes the three most commonly used rdf:type values in your graph.
  2. Restrict results to the three most common predicates. We pre-populate and comment out a VALUES statement which, when added to your query, will restrict your results to statements with any of the specified predicate(s). The statement includes the three most commonly used predicates in your graph.
  3. Get a human-readable value for the subject. We comment out an OPTIONAL block where the appropriate predicate (e.g. rdfs:label or dc:alternate) would go. When you fill in the proper predicate and add the variable to your SELECT, the query results will include labels for the subjects of matching statements.

Pro Tips

Our customers frequently use Stardog to build Semantic Search. Below are some tips for working with Stardog’s fulltext search capabilities to build your own:

  • Stardog’s fulltext search is built on Apache Lucene. Therefore, it supports Lucene’s full query syntax. Use this for term proximity, fuzzy matching, and prefix queries.

  • To get the most out of Lucene you need to configure how it processes raw text to fit both your data and anticipated queries. For this purpose Stardog supports user-defined Lucene analyzers. This provides support for synonym expansion, keyword identification, and stopword filtering, for example.

  • If you want to embed a fulltext search in a broader SPARQL query, you may want to use the service form, demonstrated below. This form supports using a SPARQL variable for the lucene input, meaning it can be determined by the rest of your SPARQL query, taking full advantage of everything the Stardog knowledge graph platform has to offer when performing a fulltext search.

  • Also, passage highlighting is supported as of Stardog 7.0.1! This is a great way to show users why each search result is returned – it wraps matching passages in HTML <b> tags.

prefix fts: <tag:stardog:api:search:>
prefix fpds: <https://www.fpds.gov/class/>
select ?s ?p ?l ?score ?h {
  ?s a fpds:AwardContract ; ?p ?l .
  service fts:textMatch {
    [] fts:result ?l ;
        fts:query "mission planning" ;
        fts:score ?score ;
        fts:highlight ?h ;
        fts:highlightMaxPassages 2 .
  }
}
order by desc(?score)
limit 100

What’s Next?

We hope this search shortcut makes it easier to access fulltext search and find what you’re looking for. If there are other Stardog features or query patterns that might be a good fit for this type of shortcut, please let us know in our community forums.

download our free e-guide

Knowledge Graphs 101

How to Overcome a Major Enterprise Liability and Unleash Massive Potential

Download for free
ebook