From c9f2a956e112773e0271e7525280ab58c06056f2 Mon Sep 17 00:00:00 2001
From: esikkala <esko.ikkala@aalto.fi>
Date: Tue, 26 Feb 2019 15:40:12 +0200
Subject: [PATCH] Facet query: fix instance counting

---
 src/server/sparql/Facets.js               | 6 +++---
 src/server/sparql/SparqlQueriesGeneral.js | 4 ----
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/server/sparql/Facets.js b/src/server/sparql/Facets.js
index dc0b0cf2..fdc30a7e 100644
--- a/src/server/sparql/Facets.js
+++ b/src/server/sparql/Facets.js
@@ -34,7 +34,7 @@ export const getFacet = (resultClass, facetID, sortBy, sortDirection, filters) =
             UNION
             {
               ${generateFacetFilterParents(resultClass, facetID, filters)}
-              ?instance ${facetConfig.parentPredicate} ?id .
+              ?different_instance ${facetConfig.parentPredicate} ?id .
               BIND(COALESCE(?selected_, false) as ?selected)
               OPTIONAL { ?id skos:prefLabel ?prefLabel_ }
               BIND(COALESCE(STR(?prefLabel_), STR(?id)) AS ?prefLabel)
@@ -51,7 +51,7 @@ export const getFacet = (resultClass, facetID, sortBy, sortDirection, filters) =
   q = q.replace('<FACET_VALUE_FILTER>', facetConfig.facetValueFilter);
   q = q.replace('<PARENTS>', parentBlock);
   q = q.replace('<ORDER_BY>', `ORDER BY ${sortDirection}(?${sortBy})` );
-  // if (facetID == 'source') {
+  // if (facetID == 'productionPlace') {
   //   console.log(prefixes + q)
   // }
   return sparqlSearchEngine.doSearch(prefixes + q, endpoint, mapper);
@@ -76,7 +76,7 @@ const generateFacetFilterParents = (resultClass, facetID, filters) => {
     if (property !== facetID) {
       filterStr += `
               VALUES ?${property}FilterParents { <${filters[property].join('> <')}> }
-              ?instance ${facetConfigs[resultClass][property].predicate} ?${property}FilterParents .
+              ?different_instance ${facetConfigs[resultClass][property].predicate} ?${property}FilterParents .
       `;
     }
   }
diff --git a/src/server/sparql/SparqlQueriesGeneral.js b/src/server/sparql/SparqlQueriesGeneral.js
index f47f9874..c68c9be2 100644
--- a/src/server/sparql/SparqlQueriesGeneral.js
+++ b/src/server/sparql/SparqlQueriesGeneral.js
@@ -40,10 +40,6 @@ export const facetValuesQuery = `
             BIND(COALESCE(?selected_, false) as ?selected)
             OPTIONAL { ?id dct:source ?source . }
             OPTIONAL { ?id gvp:broaderPreferred ?parent_ . }
-            OPTIONAL {
-              ?id wgs84:lat ?lat ;
-                  wgs84:long ?long .
-            }
             BIND(COALESCE(?parent_, '0') as ?parent)
           }
           <PARENTS>
-- 
GitLab