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: [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]
