Nested Queries & two filters within one query

19 views
Skip to first unread message

Vaishali R

unread,
Jul 8, 2021, 11:20:43 AM7/8/21
to RDF4J Users
Hi,

Two filters within one query:
I have initialised a pattern for a query using GraphPattern, that looks something like this:

GraphPattern query3 = letter.isA(lsl.iri("letter")).
andHas(lsl.iri("field"), otherFieldStore).
[...]
filter(Expressions.and(endDateGreaterThan, startDateLessThan)).
filter(Expressions.equals(otherRent, rent));

This simply does not include the date filter and skips straight to the rent filter.

What I am trying to achieve is two separate filters like this: 
FILTER(?endDate < NOW() && ?startDate < NOW()) . 
FILTER(?otherRent = ?rent) . \

How can I achieve this?



Nested Queries:
I have initialised a number of patterns (similar to above) using GraphPattern, as I would like to write a nested query.

I have tried to do so like this:

SelectQuery combinedQuery = Queries.SELECT(field, lessCount, equalCount).where().
select(countOtherLetter.as(equalCount), field).
where(query3).groupBy(field);

which gives me the following: SELECT ?fields ?lessCount ?equalCount ( COUNT( ?otherLetter ) AS ?equalCount ) ?field
WHERE { ?otherLetter a :Letter 
[...]
}


But what I am trying to achieve is this:

SELECT ?field ?lessCount ?equalCount WHERE {
      {
            SELECT (COUNT(?otherLetter) AS ?equalCount) ?field WHERE 
[...]
      }
}

How can I achieve this? I've viewed all of the above using a logger in my java code. Any help would be appreciated! :)

Vaishali

Jeen Broekstra

unread,
Jul 17, 2021, 2:26:06 AM7/17/21
to RDF4J Users
Could you perhaps provide slightly more complete code examples? It's hard to understand what you're trying to do from the fragments you're providing.

What would be really helpful is that your code examples are complete enough for me to copy-paste into a main method and then just immediately run.

Thanks,

Jeen

PS as indicated, we will be closing this mailinglist. Can I suggest that you post your question at the new Github Discussion board instead? See https://github.com/eclipse/rdf4j/discussions .
--
You received this message because you are subscribed to the Google Groups "RDF4J Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rdf4j-users...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages