You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@jena.apache.org by "cgrain (via GitHub)" <gi...@apache.org> on 2025/09/23 10:20:26 UTC
[I] No results while results are expected [jena]
cgrain opened a new issue, #3463:
URL: https://github.com/apache/jena/issues/3463
### Version
5.5
### What happened?
I have executed the query below. I expected results, since the same query gives results on a graph DB engine (and the logic should show results, as well).
The query is focused on showing either the roots of a hierarchy, or on showing elements that fit the search. I expected a UNION should do the trick, as based on the filters shown. i.e. if the search is empty, show the roots, if not, show the search results. (The line where `search_term` is modified by an external script).
```
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX nen2660: <https://w3id.org/nen2660/def#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT DISTINCT *
WHERE {
# Bind the search term at the top level, as intended.
# This makes the variable accessible to both UNION branches.
BIND('' AS ?search_term) .
# ?iri a/rdfs:subClassOf* nen2660:RealObject .
OPTIONAL {
# This branch handles finding roots.
# It will only execute if ?search_term is empty.
FILTER(?search_term = '')
?iri_parent skos:prefLabel ?iriLabel .
?iri_parent rdfs:subClassOf* nen2660:RealObject .
# Find an IRI that is not the object of a hasPart relationship.
FILTER NOT EXISTS {
?parent1 nen2660:hasPart ?iri_parent .
}
BIND("R" AS ?Test )
}
OPTIONAL {
# This branch handles the search functionality.
# It will only execute if ?search_term is not empty.
FILTER(?search_term != '')
?iri_search rdfs:subClassOf* nen2660:RealObject .
# Perform a case-insensitive search on label and notation.
?iri_search skos:prefLabel ?labelSearch .
FILTER (regex(?labelSearch, ?search_term, "i")) .
BIND("S" AS ?Test )
}
BIND ( COALESCE (?iri_search, ?iri_parent ) AS ?iri ) .
OPTIONAL {
?iri nen2660:hasPart ?child.
BIND(true AS ?inner_hasChildren) .
}
BIND(COALESCE(?inner_hasChildren, false) as ?hasChildren) .
}
```
### Relevant output and stacktrace
```shell
```
### Are you interested in making a pull request?
None
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
Re: [I] No results while results are expected [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on issue #3463:
URL: https://github.com/apache/jena/issues/3463#issuecomment-3325730007
> This query doesn't contain results.
The first part -- `BIND('' AS ?search_term)` -- is joined to the _results_ of the `UNION`.
`?search_term` is undefined within the each branch of the union so there are no results from either UNION branch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
Re: [I] No results while results are expected [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on issue #3463:
URL: https://github.com/apache/jena/issues/3463#issuecomment-3383251650
Response provided.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
Re: [I] No results while results are expected [jena]
Posted by "cgrain (via GitHub)" <gi...@apache.org>.
cgrain commented on issue #3463:
URL: https://github.com/apache/jena/issues/3463#issuecomment-3323608918
This is the data I have used. I have uploaded the triples to Apache Jena Fuseki.
[iasset_20250612111206_2025-09-23_1135.txt](https://github.com/user-attachments/files/22492741/iasset_20250612111206_2025-09-23_1135.txt)
I did have an alternative query that did produce results. I do no prefer to use this query because I suspect a negative impact on performance.
```PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX nen2660: <https://w3id.org/nen2660/def#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT DISTINCT *
WHERE {
# Bind the search term at the top level, as intended.
# This makes the variable accessible to both UNION branches.
BIND('' AS ?search_term) .
# ?iri a/rdfs:subClassOf* nen2660:RealObject .
OPTIONAL {
# This branch handles finding roots.
# It will only execute if ?search_term is empty.
FILTER(?search_term = '')
?iri_parent skos:prefLabel ?iriLabel .
?iri_parent rdfs:subClassOf* nen2660:RealObject .
# Find an IRI that is not the object of a hasPart relationship.
FILTER NOT EXISTS {
?parent1 nen2660:hasPart ?iri_parent .
}
BIND("R" AS ?Test )
}
OPTIONAL {
# This branch handles the search functionality.
# It will only execute if ?search_term is not empty.
FILTER(?search_term != '')
?iri_search rdfs:subClassOf* nen2660:RealObject .
# Perform a case-insensitive search on label and notation.
?iri_search skos:prefLabel ?labelSearch .
FILTER (regex(?labelSearch, ?search_term, "i")) .
BIND("S" AS ?Test )
}
BIND ( COALESCE (?iri_search, ?iri_parent ) AS ?iri ) .
OPTIONAL {
?iri nen2660:hasPart ?child.
BIND(true AS ?inner_hasChildren) .
}
BIND(COALESCE(?inner_hasChildren, false) as ?hasChildren) .
}
```
Notice that I have only replaced the union with 2 OPTIONALS, which show alternating results, depending on if the search term contains text or not.
These are the results I expect:
```
"search_term","iri_parent","iriLabel","Test","iri_search","labelSearch","iri","child","inner_hasChildren","hasChildren"
"","http://hub.laces.tech/semmtech/consultancy/demonstrations/industries/infrastructure/otl/iasset/64cd7405-562d-424e-8c2f-cefd1b37d2ab","Uithouder","R",,,"http://hub.laces.tech/semmtech/consultancy/demonstrations/industries/infrastructure/otl/iasset/64cd7405-562d-424e-8c2f-cefd1b37d2ab",,,"false"
"","http://data.semmtech.com/sem/def/Agent","agent","R",,,"http://data.semmtech.com/sem/def/Agent",,,"false"
"","https://w3id.org/nen2660/def#RealObject","physical object","R",,,"https://w3id.org/nen2660/def#RealObject",,,"false"
"","http://data.semmtech.com/sem/def/Agent","actor","R",,,"http://data.semmtech.com/sem/def/Agent",,,"false"
"","http://hub.laces.tech/semmtech/consultancy/demonstrations/industries/infrastructure/otl/iasset/de7afcae-2970-4da5-b4d4-a7c66ab4265d","Spandraad","R",,,"http://hub.laces.tech/semmtech/consultancy/demonstrations/industries/infrastructure/otl/iasset/de7afcae-2970-4da5-b4d4-a7c66ab4265d",,,"false"
"","http://hub.laces.tech/semmtech/consultancy/demonstrations/industries/infrastructure/otl/iasset/f74af932-7bfb-4f5c-abe8-dd281ca4629f","Armatuur","R",,,"http://hub.laces.tech/semmtech/consultancy/demonstrations/industries/infrastructure/otl/iasset/f74af932-7bfb-4f5c-abe8-dd281ca4629f",,,"false"
"","http://hub.laces.tech/semmtech/consultancy/demonstrations/industries/infrastructure/otl/iasset/d1f059a2-f759-4b0f-8994-39a8daeee246","Lichtbron","R",,,"http://hub.laces.tech/semmtech/consultancy/demonstrations/industries/infrastructure/otl/iasset/d1f059a2-f759-4b0f-8994-39a8daeee246",,,"false"
"","https://w3id.org/nen2660/def#RealObject","fysiek object","R",,,"https://w3id.org/nen2660/def#RealObject",,,"false"
```
These are the results I get:
```
"search_term","iri_parent","iriLabel","Test","iri_search","labelSearch","iri","child","inner_hasChildren","hasChildren"
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
Re: [I] No results while results are expected [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on issue #3463:
URL: https://github.com/apache/jena/issues/3463#issuecomment-3323572296
Hi @cgrain ,
Without data this isn't reproducible.
How are you storing the data? and how are you executing the query?
If you're not getting results, the first thing to do is simplify the query by removing parts until you do get some results.
> on a graph DB engine
That would be a Ontotext GraphDB database?
Are you using named graphs at all?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
Re: [I] No results while results are expected [jena]
Posted by "cgrain (via GitHub)" <gi...@apache.org>.
cgrain commented on issue #3463:
URL: https://github.com/apache/jena/issues/3463#issuecomment-3323689970
My bad, I was too much busy debugging my original query, so I unintentially shared the quote-unquote 'fixed' query.
I was wondering about issues with the following query:
```
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX nen2660: <https://w3id.org/nen2660/def#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT DISTINCT *
WHERE {
# Bind the search term at the top level, as intended.
# This makes the variable accessible to both UNION branches.
BIND('' AS ?search_term) .
# ?iri a/rdfs:subClassOf* nen2660:RealObject .
{
# This branch handles finding roots.
# It will only execute if ?search_term is empty.
FILTER(?search_term = '')
?iri_parent skos:prefLabel ?iriLabel .
?iri_parent rdfs:subClassOf* nen2660:RealObject .
# Find an IRI that is not the object of a hasPart relationship.
FILTER NOT EXISTS {
?parent1 nen2660:hasPart ?iri_parent .
}
BIND("R" AS ?Test )
}
UNION {
# This branch handles the search functionality.
# It will only execute if ?search_term is not empty.
FILTER(?search_term != '')
?iri_search rdfs:subClassOf* nen2660:RealObject .
# Perform a case-insensitive search on label and notation.
?iri_search skos:prefLabel ?labelSearch .
FILTER (regex(?labelSearch, ?search_term, "i")) .
BIND("S" AS ?Test )
}
BIND ( COALESCE (?iri_search, ?iri_parent ) AS ?iri ) .
OPTIONAL {
?iri nen2660:hasPart ?child.
BIND(true AS ?inner_hasChildren) .
}
BIND(COALESCE(?inner_hasChildren, false) as ?hasChildren) .
}
```
This query doesn't contain results.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
Re: [I] No results while results are expected [jena]
Posted by "Aklakan (via GitHub)" <gi...@apache.org>.
Aklakan commented on issue #3463:
URL: https://github.com/apache/jena/issues/3463#issuecomment-3346021186
I recall that there were databases that would incorrectly inject bindings into unions. You can check with this query:
```sparql
SELECT * {
BIND("foo" AS ?foo)
{ BIND(?foo AS ?bar) } UNION { BIND(?foo AS ?baz) }
}
```
The expected result is this:
```
---------------------
| foo | bar | baz |
=====================
| "foo" | | |
| "foo" | | |
---------------------
```
Note: With Jena and Oxigraph (perhaps some more stores by now?), you can use the `LATERAL` keyword to inject bindings from from the left-hand side (lhs) to the right-hand one before the rhs gets evaluated. Unfortunately, this is not yet standard/portable.
```sparql
SELECT * {
BIND("foo" AS ?foo)
LATERAL {
{ BIND(?foo AS ?bar) } UNION { BIND(?foo AS ?baz) }
}
}
```
```
-------------------------
| foo | bar | baz |
=========================
| "foo" | "foo" | |
| "foo" | | "foo" |
-------------------------
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
Re: [I] No results while results are expected [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs closed issue #3463: No results while results are expected
URL: https://github.com/apache/jena/issues/3463
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
Re: [I] No results while results are expected [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on issue #3463:
URL: https://github.com/apache/jena/issues/3463#issuecomment-3323652639
The two queries are the same, except the second is missing `PREFIX rdfs:`
query + data gives me 8 results
```
sparql --results csv --data _iassets_ --query _query1 in a file_
```
```
search_term,iri_parent,iriLabel,Test,iri_search,labelSearch,iri,child,inner_hasChildren,hasChildren
"",http://hub.laces.tech/semmtech/consultancy/demonstrations/industries/infrastructure/otl/iasset/64cd7405-562d-424e-8c2f-cefd1b37d2ab,Uithouder,R,,,http://hub.laces.tech/semmtech/consultancy/demonstrations/industries/infrastructure/otl/iasset/64cd7405-562d-424e-8c2f-cefd1b37d2ab,,,false
"",http://data.semmtech.com/sem/def/Agent,agent,R,,,http://data.semmtech.com/sem/def/Agent,,,false
"",https://w3id.org/nen2660/def#RealObject,physical object,R,,,https://w3id.org/nen2660/def#RealObject,,,false
"",http://data.semmtech.com/sem/def/Agent,actor,R,,,http://data.semmtech.com/sem/def/Agent,,,false
"",http://hub.laces.tech/semmtech/consultancy/demonstrations/industries/infrastructure/otl/iasset/de7afcae-2970-4da5-b4d4-a7c66ab4265d,Spandraad,R,,,http://hub.laces.tech/semmtech/consultancy/demonstrations/industries/infrastructure/otl/iasset/de7afcae-2970-4da5-b4d4-a7c66ab4265d,,,false
"",http://hub.laces.tech/semmtech/consultancy/demonstrations/industries/infrastructure/otl/iasset/f74af932-7bfb-4f5c-abe8-dd281ca4629f,Armatuur,R,,,http://hub.laces.tech/semmtech/consultancy/demonstrations/industries/infrastructure/otl/iasset/f74af932-7bfb-4f5c-abe8-dd281ca4629f,,,false
"",http://hub.laces.tech/semmtech/consultancy/demonstrations/industries/infrastructure/otl/iasset/d1f059a2-f759-4b0f-8994-39a8daeee246,Lichtbron,R,,,http://hub.laces.tech/semmtech/consultancy/demonstrations/industries/infrastructure/otl/iasset/d1f059a2-f759-4b0f-8994-39a8daeee246,,,false
"",https://w3id.org/nen2660/def#RealObject,fysiek object,R,,,https://w3id.org/nen2660/def#RealObject,,,false
```
The first line is the CSV header, not part of the results.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org