Skip to content

Commit

Permalink
query improvements
Browse files Browse the repository at this point in the history
- use of lucene index
- lucene score for ranking
- scopeNote better reflecting type of street
  • Loading branch information
coret committed Feb 7, 2023
1 parent 4f79257 commit 0a506d8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
Expand Up @@ -20,13 +20,11 @@ CONSTRUCT {
dcterms:identifier ?identifier ;
skos:prefLabel ?prefLabel .
FILTER (CONTAINS(STR(?uri), "ark:"))
?uri hg:liesIn <https://n2t.net/ark:/60537/buzpEa> .
BIND ( CONCAT( IF ( EXISTS { ?uri omeka:item_set <https://n2t.net/ark:/60537/bd75pg> }, "Verdwenen straat", "Straat" )," in Gouda") AS ?scopeNote )
OPTIONAL {
?uri skos:altLabel ?altLabel
}
OPTIONAL {
?uri hg:liesIn/schema:sameAs <http://sws.geonames.org/2755419/> # Gouda
BIND("Straat in Gouda" AS ?scopeNote)
}
OPTIONAL {
?uri hg:absorbedBy|hg:absorbed ?related_uri .
?related_uri a gtm:Straat ;
Expand Down
Expand Up @@ -3,31 +3,39 @@ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX gtm: <https://www.goudatijdmachine.nl/def#>
PREFIX schema: <https://schema.org/>
PREFIX hg: <http://rdf.histograph.io/>
PREFIX luc: <http://www.ontotext.com/connectors/lucene#>
PREFIX luc-index: <http://www.ontotext.com/connectors/lucene/instance#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX vrank: <http://purl.org/voc/vrank#>
PREFIX omeka: <http://omeka.org/s/vocabs/o#>

CONSTRUCT {
?uri a skos:Concept ;
skos:prefLabel ?prefLabel ;
skos:altLabel ?altLabel;
skos:scopeNote ?scopeNote ;
skos:related ?related_uri .
skos:related ?related_uri ;
vrank:simpleRank ?score .
?related_uri skos:prefLabel ?related_prefLabel .
}
WHERE {
?uri a gtm:Straat ;
dcterms:identifier ?identifier ;
skos:prefLabel ?prefLabel .
OPTIONAL { ?uri skos:altLabel ?altLabel . }
} FROM <http://www.ontotext.com/retain-bind-position> WHERE {
BIND(CONCAT("*",?query,"*") AS ?zoekterm)
?search a luc-index:straat_index ;
luc:query ?zoekterm ;
luc:entities ?entity .
?entity owl:sameAs ?uri .
FILTER (CONTAINS(STR(?uri), "ark:"))
?uri hg:liesIn <https://n2t.net/ark:/60537/buzpEa> .
?entity dcterms:identifier ?identifier ;
skos:prefLabel ?prefLabel ;
luc:score ?score .
BIND ( CONCAT( IF ( EXISTS { ?uri omeka:item_set <https://n2t.net/ark:/60537/bd75pg> }, "Verdwenen straat", "Straat" )," in Gouda") AS ?scopeNote )
OPTIONAL {
?uri hg:liesIn/schema:sameAs <http://sws.geonames.org/2755419/> # Gouda
BIND("Straat in Gouda" AS ?scopeNote)
?uri skos:altLabel ?altLabel .
}
OPTIONAL {
?uri hg:absorbedBy|hg:absorbed ?related_uri .
?related_uri a gtm:Straat ;
skos:prefLabel ?related_prefLabel .
FILTER (CONTAINS(STR(?related_uri), "ark:") && ?uri != ?related_uri )
skos:prefLabel ?related_prefLabel .
FILTER (CONTAINS(STR(?related_uri), "ark:") && ?uri != ?related_uri )
}
FILTER (CONTAINS(STR(?uri), "ark:"))
FILTER (CONTAINS(LCASE(?prefLabel),?query) || CONTAINS(LCASE(?altLabel),?query) )
}
LIMIT 100
} ORDER BY DESC(?score) LIMIT 100

4 comments on commit 0a506d8

@coret
Copy link
Contributor Author

@coret coret commented on 0a506d8 Apr 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improved query gives "Cannot read properties of undefined (reading '0')" when run via GraphQL API (see below), problem identified by @ddeboer in Comunica component, he made issue comunica/comunica#1154

query {
  terms(
    sources: ["https://www.goudatijdmachine.nl/id/straten#streets"],
    query: "markt",

  ) {
    source {
      uri
      name
      creators {
        uri
        name
        alternateName
      }
    }
    result {
      __typename
      ... on Terms {
        terms {
          uri
          prefLabel
          altLabel
          hiddenLabel
          scopeNote
          seeAlso
          broader {
            uri
            prefLabel
          }
          narrower {
            uri
            prefLabel
          }
          related {
            uri
            prefLabel
          }
        }
      }
      ... on Error {
        message
      }
    }
    responseTimeMs
  }
}

@EnnoMeijers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my understanding: which part of the improved query is triggering the bug in Comunica?

@ddeboer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comunica/comunica#1154: the bug is caused by querying a named graph CONSTRUCT FROM <http://www.ontotext.com/retain-bind-position>.

@EnnoMeijers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks for clearing this up!

Please sign in to comment.