researchspace / researchspace

ResearchSpace Platform
Other
118 stars 36 forks source link

Filter semantic search by named graph #237

Closed linkedDataDeveloper closed 3 years ago

linkedDataDeveloper commented 3 years ago

In the metaphactory documentation, there is description of a property datasets-config that can be defined in semantic search to limit the query to a particular named graph. When used in RS, an error Cannot read property 'map' of undefined is returned. Can this functionality be adopted by RS, or is there a canonical method of limiting search results by named graph? For example, I am currently using the following query:

      query='
        SELECT ?subject WHERE { 
            GRAPH ?src {
             ?subject a ?type .
             ?type rdfs:subClassOf* crm:E1_CRM_Entity .
             ?subject rdfs:label ?label .
           }
           FILTER(str(?src)="http://graph.lincsproject.ca/yellow1890s")
           FILTER(REGEX(STR(?label), ?__token__))
        }
      '
linkedDataDeveloper commented 3 years ago

Moreover, the above method of filtering by named graph has introduced unexpected and inconsistent results for faceting. See https://gitlab.com/calincs/infrastructure/lincs-rs-custom-app/-/issues/32

linkedDataDeveloper commented 3 years ago

Fixed using the following:

          query='
            SELECT ?subject WHERE { 
                GRAPH <http://graph.lincsproject.ca/adarchive> {
                 ?subject a ?type .
                 ?type rdfs:subClassOf* frbroo:F2_Expression .
                 ?subject rdfs:label ?label .
                }
              SERVICE <http://www.bigdata.com/rdf/search#search> {
                 ?label bds:search ?__token__ ;
                          bds:minRelevance "0.3" ;
                          bds:matchAllTerms "true"  .
                    }
          }
          '
          default-query='
              SELECT ?subject WHERE { 
                GRAPH <http://graph.lincsproject.ca/adarchive> {
                 ?subject a ?type .
                 ?type rdfs:subClassOf* frbroo:F2_Expression .
                }
              }