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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
