Search code examples
sparqlwikidatawikidata-query-service

How to create a SPARQL query to search Wikidata item descriptions


I'd like to be able to find an item based on words in its descriptions.

This is what I'm trying to do, but clearly I don't know what I'm doing. Any help is appreciated.

SELECT ?item ?itemLabel WHERE {
 
  ?item schema:description ?desc.
  FILTER(CONTAINS(LCASE(?desc), "space telescope"))
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

LIMIT 10

Solution

  • Solved by UninformedUser in the comments!

    WHERE {   hint:Query hint:optimizer "None".   
           SERVICE wikibase:mwapi {     
             bd:serviceParam wikibase:api "Search";                     
             wikibase:endpoint "www.wikidata.org";                     
             mwapi:srsearch "space telescope".     
             ?item wikibase:apiOutputItem mwapi:title .   }      
             SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } 
             
    } 
    
    limit 10