buda-base / lds-queries

A repository for BUDA Linked Data Server
Apache License 2.0
0 stars 1 forks source link

Query warning in Fuseki - issue or not? #32

Closed xristy closed 4 years ago

xristy commented 4 years ago

While looking at Fuseki catalina.out, I noticed a cluster of TextQueryPF WARNings from the following eText query.

These warnings indicate that text:query will produce no results.

It's sure not obvious why these warnings are happening, and there is just this one occurrence in this log.

[2020-04-30 13:09:46] Fuseki     INFO  [86] POST http://buda1.bdrc.io:13180/fuseki/newcorerw/query
[2020-04-30 13:09:46] Fuseki     INFO  [86] Query =
    PREFIX bdr: <http://purl.bdrc.io/resource/>
    PREFIX : <http://purl.bdrc.io/ontology/core/>
    PREFIX adm: <http://purl.bdrc.io/ontology/admin/>
    PREFIX tmp: <http://purl.bdrc.io/ontology/tmp/>
    PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
    PREFIX bdo: <http://purl.bdrc.io/ontology/core/>
    PREFIX bda: <http://purl.bdrc.io/admindata/>
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    PREFIX owl: <http://www.w3.org/2002/07/owl#> 
    prefix text:  <http://jena.apache.org/text#>   
    construct {   
      ?etext tmp:isMain true .   
      ?etext skos:prefLabel ?etextL .   
      ?etext bdo:eTextHasChunk ?chunk .    
      ?chunk bdo:chunkContents ?lit .   
      ?chunk bdo:sliceStartChar ?startChar .   
      ?chunk bdo:sliceEndChar ?endChar .   
      ?chunk tmp:matchScore ?score .   
      ?etext tmp:provider ?provider .    
      ?etext ?etextp ?etexto .      
      ?etext tmp:forWork ?w .   
      ?w ?wp ?wo .    
      ?etext tmp:author ?author .   
      ?agent skos:prefLabel ?agentL .    
      ?etext tmp:maxScore ?maxScore .   
      ?etext tmp:nbChunks ?nbchunks . 
    } where {   
      bind("ston dri med 'od zer"@bo-x-ewts as ?L_NAME) .    
      {  
         (?chunk ?score ?lit) text:query ( :chunkContents ?L_NAME "highlight:") .     
         ?etext bdo:eTextHasChunk ?chunk .     
         ?etext bdo:eTextInInstance ?einstance .      
         ?eAdm adm:adminAbout ?einstance .     
         ?eAdm adm:status bda:StatusReleased .     
         ?w :workHasInstance ?einstance .      
         ?chunk bdo:sliceStartChar ?startChar .     
         ?chunk bdo:sliceEndChar ?endChar .     
         ?eAdm adm:metadataLegal/adm:provider ?provider .     
         ?w ?wp ?wo .     
         FILTER (?wp IN(skos:altLabel , skos:prefLabel , rdf:type , owl:sameAs , tmp:entityScore))    
      } union {      
         (?chunk ?score ?lit) text:query ( :chunkContents ?L_NAME "highlight:") .     
         ?etext bdo:eTextHasChunk ?chunk .     
         VALUES ?etextp { skos:prefLabel bdo:eTextIsVolume }     
         ?etext ?etextp ?etexto .      
         ?chunk bdo:sliceStartChar ?startChar .     
         ?chunk bdo:sliceEndChar ?endChar .    
      } union {     
         ?chunk text:query ( :chunkContents ?L_NAME ) .     
         ?etext bdo:eTextHasChunk ?chunk .     
         ?etext bdo:eTextInInstance ?einstance .     
         ?eAdm adm:adminAbout ?einstance .     
         ?eAdm adm:status bda:StatusReleased .     
         ?w :workHasInstance ?einstance .      
         ?w bdo:creator ?creator .     
         ?creator bdo:role ?role .     
         ?creator bdo:agent ?agent .     
         ?agent skos:prefLabel ?agentL .            
         bind( if(?role IN(bdr:R0ER0014 , bdr:R0ER0016 , bdr:R0ER0019 , bdr:R0ER0025), ?agent, 1/0) as ?author)   
      } union {      
         select ?etext (count (?chunk) as ?nbchunks) (max (?score) as ?maxScore) 
         where {       
            (?chunk ?score) text:query ( :chunkContents ?L_NAME) .       
            ?etext bdo:eTextHasChunk ?chunk .       
         } group by ?etext    
      }  
    } 
[2020-04-30 13:09:46] TextQueryPF WARN  Text query string is not a literal [http://purl.bdrc.io/ontology/core/chunkContents, ?L_NAME, "highlight:"] AT idx: 1
[2020-04-30 13:09:46] TextQueryPF WARN  Text query string is not a literal [http://purl.bdrc.io/ontology/core/chunkContents, ?L_NAME, "highlight:"] AT idx: 1
[2020-04-30 13:09:46] TextQueryPF WARN  Text query string is not a literal [http://purl.bdrc.io/ontology/core/chunkContents, ?L_NAME, "highlight:"] AT idx: 1
[2020-04-30 13:09:46] TextQueryPF WARN  Text query string is not a literal [http://purl.bdrc.io/ontology/core/chunkContents, ?L_NAME] AT idx: 1
[2020-04-30 13:09:46] TextQueryPF WARN  Text query string is not a literal [http://purl.bdrc.io/ontology/core/chunkContents, ?/L_NAME] AT idx: 1
[2020-04-30 13:09:46] Fuseki     INFO  [86] 200 OK (14 ms)
eroux commented 4 years ago

it doesn't seem to come from any of the queries in this repo... @MarcAgate @berger-n do you remember trying this by hand on the Fuseki interface?

berger-n commented 4 years ago

I do before opening https://github.com/buda-base/lds-queries/issues/31 query is https://github.com/buda-base/lds-queries/blob/newbiblio/library/etextContentFacetGraph.arq but I could not get any result copy/pasting it on Fuseki interface ...

eroux commented 4 years ago

ok thanks!

eroux commented 4 years ago

(just to be a bit clearer: in this query you can't just bind ?L_NAME, you need to substitute it in all instances where it appears)

xristy commented 4 years ago

Interesting. I hadn't paid attention that bind doesn't propagate into { . . . } so has to be repeated in each block. Rather a gnarly feature of sparql.

berger-n commented 4 years ago

@eroux @xristy thanks for the explanation still the query using text substitution does not yield any result in Fuseki interface I don't know what I'm missing here:

PREFIX bdr: <http://purl.bdrc.io/resource/>
PREFIX : <http://purl.bdrc.io/ontology/core/>
PREFIX adm: <http://purl.bdrc.io/ontology/admin/>
PREFIX tmp: <http://purl.bdrc.io/ontology/tmp/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX bdo: <http://purl.bdrc.io/ontology/core/>
PREFIX bda: <http://purl.bdrc.io/admindata/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
prefix text:  <http://jena.apache.org/text#>

construct {
  ?etext tmp:isMain true .
  ?etext skos:prefLabel ?etextL .
  ?etext bdo:eTextHasChunk ?chunk .

  ?chunk bdo:chunkContents ?lit .
  ?chunk bdo:sliceStartChar ?startChar .
  ?chunk bdo:sliceEndChar ?endChar .
  ?chunk tmp:matchScore ?score .
  ?etext tmp:provider ?provider .

  ?etext ?etextp ?etexto .

  ?etext tmp:forWork ?w .
  ?w ?wp ?wo .

  ?etext tmp:author ?author .
  ?agent skos:prefLabel ?agentL .

  ?etext tmp:maxScore ?maxScore .
  ?etext tmp:nbChunks ?nbchunks .
}
where
{
  {
    (?chunk ?score ?lit) text:query ( :chunkContents "ston dri med 'od zer"@bo-x-ewts "highlight:") .
    ?etext bdo:eTextHasChunk ?chunk .
    ?etext bdo:eTextInInstance ?einstance .

    ?eAdm adm:adminAbout ?einstance .
    ?eAdm adm:status bda:StatusReleased .
    ?w :workHasInstance ?einstance .

    ?chunk bdo:sliceStartChar ?startChar .
    ?chunk bdo:sliceEndChar ?endChar .
    ?eAdm adm:metadataLegal/adm:provider ?provider .
    ?w ?wp ?wo .
    FILTER (?wp IN(skos:altLabel , skos:prefLabel , rdf:type , owl:sameAs , tmp:entityScore))

  } union {

    (?chunk ?score ?lit) text:query ( :chunkContents "ston dri med 'od zer"@bo-x-ewts "highlight:") .
    ?etext bdo:eTextHasChunk ?chunk .
    VALUES ?etextp { skos:prefLabel bdo:eTextIsVolume }
    ?etext ?etextp ?etexto .

  } union {
    ?chunk text:query ( :chunkContents "ston dri med 'od zer"@bo-x-ewts ) .
    ?etext bdo:eTextHasChunk ?chunk .
    ?etext bdo:eTextInInstance ?einstance .
    ?eAdm adm:adminAbout ?einstance .
    ?eAdm adm:status bda:StatusReleased .
    ?w :workHasInstance ?einstance .

    ?w bdo:creator ?creator .
    ?creator bdo:role ?role .
    ?creator bdo:agent ?agent .
    ?agent skos:prefLabel ?agentL .

    bind( if(?role IN(bdr:R0ER0014 , bdr:R0ER0016 , bdr:R0ER0019 , bdr:R0ER0025), ?agent, 1/0) as ?author)
  } union {

    select ?etext (count (?chunk) as ?nbchunks) (max (?score) as ?maxScore) where {
      (?chunk ?score) text:query ( :chunkContents "ston dri med 'od zer"@bo-x-ewts) .
      ?etext bdo:eTextHasChunk ?chunk .  
    } group by ?etext 
  }
}
xristy commented 4 years ago

@berger-n The query-string should be double-quoted as a phrase:

?chunk text:query ( :chunkContents "\"ston dri med 'od zer\""@bo-x-ewts )

As written it is an OR of the terms which typically should produce lots more results than the phrase, so there must be some other issue if you're getting no results.

When I run just the text:query w/o the phrase quoting there are 9990 results and with the quotes there are 11 results

berger-n commented 4 years ago

glad to know! thanks