# Query name : query8.4
# Query Type: 8, Cross-version structured queries
# Query Description :
# Retrieve all creative works from a set of specific versions, which contain a certain word
# in their title or description. The size of the resultset is limited by a random number
# between 1 and 1000.
# A Full-text search query.
# Choke Points :
# - OPTIONAL clauses (treated by query optimizer as nested sub-queries)
# Optimizer should decide to put optional triples on top of the join tree
# (i.e. delay their execution to the last possible moment) because OPTIONALs are treated as a left join
# - Optimizer should be able to split the FILTER conditions into conjunction of conditions and
# start their execution as soon as possible thus eliminating intermediate results
# - A possibility for optimizing the full-text search by using appropriate index
PREFIX bbc:
PREFIX cwork:
PREFIX rdfs:
SELECT DISTINCT ?creativeWork
FROM {{{graphVi}}}
{{{fromIntermediateVersionsClauses}}}
FROM {{{graphVj}}}
WHERE {
?type rdfs:subClassOf cwork:CreativeWork .
?creativeWork a ?type ;
cwork:title ?title ;
cwork:description ?description .
OPTIONAL { ?creativeWork cwork:dateCreated ?dateCreated . }
OPTIONAL { ?creativeWork cwork:category ?category . }
OPTIONAL {
?creativeWork bbc:primaryContentOf ?pco .
?pco bbc:webDocumentType ?webDocType .
}
FILTER (CONTAINS(?title, {{{word}}}) || CONTAINS(?description, {{{word}}})) .
}
ORDER BY DESC(?dateModified)
LIMIT {{{randomLimit}}}