0

I use Stardog as a semantic graph database. My database contains, for example, "apple" but not "apples", so if I query for "apples", it cannot find anything.

One possible way to solve this is to add the stem version of all the labels to the database but that is inefficient.

Since Stardog uses SPARQL query language and Lucene, how can I ask Stardog to use stemming in its search?

femtoRgon
  • 32,893
  • 7
  • 60
  • 87
Sadegh
  • 80
  • 1
  • 6

1 Answers1

1

Assuming you want English language stemming, the right analyzer to use would be EnglishAnalyzer

Stardog allows you to change your analyzer, based on their documentation. You need to implement an AnalyzerFactory, like:

public final class EnglishAnalyzerFactory implements AnalyzerFactory {
    @Override
    public Analyzer get() {
        return new EnglishAnalyzer(Version.LUCENE_47);
    }
}

Then:

Create a file called com.complexible.stardog.search.AnalyzerFactory in the META-INF/services directory. The contents of this file should be the fully-qualified class name of your AnalyzerFactory.

femtoRgon
  • 32,893
  • 7
  • 60
  • 87
  • Thank you. I did it, but it doesn't effect on my queries. I use Stardog spring, do I need any other configuration? – Sadegh May 06 '15 at 09:45
  • 1
    Did you restart the server? Also make sure the compiled class is in the classpath along with the services definition. – Michael May 07 '15 at 10:20