query-4298571543c0791e62cd98a04256ffce

rq turtle/ttl

Ejecuta esta consulta. Mientras estoy escribiendo esto, la consulta solo me devuelve nueve resultados - bastante escaso, ¿por qué sucede esto si antes encontramos cientos de libros? La razón es que para coincidir con esta consulta, un resultado potencial (un libro) debe coincidir con todas las ternas que enumeramos: debe tener un título, un ilustrador, un editor y una fecha de publicación. Si tiene algunas de esas propiedades, pero no todas, no coincidirá. Y eso no es lo que queremos en este caso: principalmente queremos una lista de todos los libros; si hay datos adicionales disponibles, nos gustaría incluirlos, pero no queremos que eso limite nuestra lista de resultados. La solución es decirle a WDQS que aquellas ternas son "opcionales":

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?libro ?título ?ilustradorLabel ?editorialLabel ?fecha_de_publicación
WHERE
{
  ?libro wdt:P50 wd:Q35610.
  OPTIONAL { ?libro wdt:P1476 ?título. }
  OPTIONAL { ?libro wdt:P110  ?ilustrador. }
  OPTIONAL { ?libro wdt:P123  ?editorial. }
  OPTIONAL { ?libro wdt:P577  ?fecha_de_publicación. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?editorial") v5("?fecha_de_publicación"):::projected v3("?ilustrador") v1("?libro"):::projected v2("?título"):::projected c8(["bd:serviceParam"]):::iri c10(["#91;AUTO_LANGUAGE#93;"]):::literal c2(["wd:Q35610"]):::iri v1 --"wdt:P50"--> c2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P1476".-> v2 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P110".-> v3 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P123".-> v4 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P577".-> v5 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end