@igea/oac_backend 1.0.49 → 1.0.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@igea/oac_backend",
3
- "version": "1.0.49",
3
+ "version": "1.0.50",
4
4
  "description": "Backend service for the OAC project",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -239,10 +239,13 @@ router.post('/search/by-prefix', (req, res) => {
239
239
  const bindings = response.data.results.bindings;
240
240
  let results = []
241
241
  bindings.forEach(result => {
242
- results.push({
243
- instance: result.instance.value,
244
- label: result.label.value,
245
- });
242
+ if(result.node){
243
+ var label = result.label ? result.label.value : "";
244
+ results.push({
245
+ instance: result.node.value,
246
+ label
247
+ });
248
+ }
246
249
  });
247
250
  res.json({
248
251
  success: true,
@@ -250,6 +253,7 @@ router.post('/search/by-prefix', (req, res) => {
250
253
  message: null
251
254
  });
252
255
  }).catch(err => {
256
+ console.log(err)
253
257
  res.status(500).json({
254
258
  success: false,
255
259
  data: null,
@@ -90,20 +90,22 @@ class Fuseki {
90
90
  if(limit < 1) limit = 50;
91
91
  return `
92
92
  PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
93
- SELECT DISTINCT ?instance ?label
93
+ SELECT ?node ?label
94
94
  WHERE {
95
- # tutte le istanze con qualsiasi proprietà
96
- ?instance ?p ?o .
97
- # filtro per IRI che inizia con il prefisso specifico
98
- FILTER(STRSTARTS(STR(?instance), "${prefix}"))
99
- # filtro per IRI che termina con UUID
100
- #FILTER(REGEX(STR(?instance), "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"))
101
- # label opzionale
102
- OPTIONAL { ?instance rdfs:label ?label . }
95
+ {
96
+ ?s ?p ?node .
97
+ FILTER (isIRI(?node) && STRSTARTS(STR(?node), "${prefix}"))
98
+ }
99
+ UNION
100
+ {
101
+ ?node ?p ?o.
102
+ FILTER (isIRI(?node) && STRSTARTS(STR(?node), "${prefix}"))
103
+ }
104
+ OPTIONAL { ?node rdfs:label ?label . }
103
105
  }
104
106
  ORDER BY ?label
105
107
  LIMIT ${limit}
106
- OFFSET ${offset}`
108
+ OFFSET ${offset}`
107
109
  }
108
110
 
109
111
  static getQuerySearchInvestigation(id, prefix='http://indagine/') {