when I run the query in stardog webconsole it returns FALSE as expected. But when I run the same query using client method : BooleanQuery ask(String var1) throws StardogException; It returns true.
Hi thx for your response.
My datasource object is a wrapper for ConnectionConfiguration (see below)
import com.complexible.stardog.StardogException;
import com.complexible.stardog.api.Connection;
import com.complexible.stardog.api.ConnectionConfiguration;
import com.complexible.stardog.api.ConnectionPool;
import com.complexible.stardog.api.ConnectionPoolConfig;
public class DataSource {
final Logger log = LoggerFactory.getLogger(DataSource.class);
private ConnectionPool pool;
private ConnectionConfiguration connectionConfig;
private ConnectionPoolConfig poolConfig;
public DataSource() { }
public DataSource(ConnectionConfiguration configuration) {
connectionConfig = configuration;
poolConfig = ConnectionPoolConfig.using(configuration);
}
public DataSource(ConnectionConfiguration configuration, ConnectionPoolConfig poolConfiguration) {
connectionConfig = configuration;
poolConfig = poolConfiguration;
}
public void afterPropertiesSet() {
log.debug("Creating Stardog connection pool");
pool = poolConfig.create();
}
/**
* <code>getConnection</code>
* Similar to javax.sql.DataSource
*
* Also serves as a place to weave in Spring transaction support
*
* @return Stardog Connection
*/
public Connection getConnection() {
try {
if (pool == null)
afterPropertiesSet();
return pool.obtain();
} catch (StardogException e) {
log.error("Error obtaining connection from Stardog pool", e);
throw new RuntimeException(e);
}
}
/**
* <code>releaseConnection</code>
* @param connection Stardog Connection
*/
public void releaseConnection(Connection connection) {
try {
if (pool == null)
afterPropertiesSet();
pool.release(connection);
} catch (StardogException e) {
log.error("Error releasing connection from Stardog pool", e);
throw new RuntimeException(e);
}
}
/**
* <code>destroy</code>
* Called by Spring
*/
public void destroy() {
try {
if (pool == null)
afterPropertiesSet();
pool.shutdown();
} catch (StardogException e) {
log.error("Error shutting down Stardog pool", e);
}
poolConfig = null;
connectionConfig = null;
pool = null;
}
To give some more info:
when I do following queries with my setup:
ASK{?s someknownpredicate ?o } returns true
ASK{?s someunknownpredicate ?o } returns false
it is only when I do
in code:
ASK{someknownsubject ?p ?o } returns true
ASK{someunknownsubject ?p ?o } returns true
but in stardog webconsole:
ASK{someknownsubject ?p ?o } returns true
ASK{someunknownsubject ?p ?o } returns false
Hi Stephen, I am answering my own question but I found that the reasoning parameter was causing the issue.
Although I am not sure why this would be a factor in this specific query.
Would you have an idea why this is the case.
This happens because, as can be seen by running a SELECT * {someunknownsubject ?p ?o} query, enabling reasoning causes a [:X rdf:type owl:Thing] triple to be inferred for any given subject, causing your very general ASK to return true.
To get around this, you can either disable reasoning or add a filter to your ask: ASK {someunknownsubject ?p ?o . FILTER (?p != rdf:type)}