From bbb2db3c4e3439df2b98b315f37d4bdced53be44 Mon Sep 17 00:00:00 2001
From: Mathieu Massaviol <mathieu.massaviol@univ-amu.fr>
Date: Wed, 13 Nov 2024 11:26:31 +0100
Subject: [PATCH] Improve getSearchResults query #68

---
 src/sparql/search.ts | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/src/sparql/search.ts b/src/sparql/search.ts
index c080794..a189450 100644
--- a/src/sparql/search.ts
+++ b/src/sparql/search.ts
@@ -153,29 +153,32 @@ export const getSearchResults = async (resourceUriList: string[], auth?: Credent
       }
       WHERE {
         VALUES ?s { ${formattedUris} }
-        VALUES ?p {
-          rdf:type
-          dct:title
-          dct:description
-          dcat:version
-          dcat:catalog
-          dcat:dataset
-          dcat:distribution
+        GRAPH ?g {
+          ?s dct:identifier ?identifier.
+        
+          VALUES ?p {
+            rdf:type
+            dct:title
+            dct:description
+            dcat:version
+            dcat:catalog
+            dcat:dataset
+            dcat:distribution
+          }
+          ?s ?p ?o.
         }
-        ?s ?p ?o.
         OPTIONAL {
           ?s dct:creator ?creator.
           VALUES ?p2 { foaf:name foaf:givenName foaf:familyName foaf:firstName }
           ?creator ?p2 ?o2.
         }
         OPTIONAL {
-          ?parentCatalog dcat:dataset|dcat:catalog ?s.
+          VALUES ?parentLink { dcat:dataset dcat:catalog }
+          ?parentCatalog a dcat:Catalog;
+                         ?parentLink ?s.
           VALUES ?pparentCatalog { dct:identifier dct:title }
           ?parentCatalog ?pparentCatalog ?oparentCatalog.
         }
-        GRAPH ?g {
-          ?s dct:identifier ?identifier.
-        }
       }
     `,
     {
-- 
GitLab