0

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
Andrew Mayne
  • 1
  • 1
  • 4
  • in theory correct, but do to the size of the dataset rather inefficient as no fulltex index is used but a full scan on all entities. You can use the MediaWiki extensions, – UninformedUser Mar 23 '22 at 04:33
  • `SELECT DISTINCT ?item ?itemLabel ?dateOfBirth 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` – UninformedUser Mar 23 '22 at 04:33
  • or this search entry point: – UninformedUser Mar 23 '22 at 04:35
  • `SELECT ?item ?itemLabel ?type ?typeLabel WHERE { SERVICE wikibase:mwapi { bd:serviceParam wikibase:api "EntitySearch" . bd:serviceParam wikibase:endpoint "www.wikidata.org" . bd:serviceParam mwapi:search "space telescope" . bd:serviceParam mwapi:language "en" . ?item wikibase:apiOutputItem mwapi:item . ?num wikibase:apiOrdinal true . } ?item (wdt:P279|wdt:P31) ?type SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } ORDER BY ASC(?num) LIMIT 10` – UninformedUser Mar 23 '22 at 04:35
  • indeed, you could add a triple pattern that does filter on specific types or at least omits e.g. scholarly articles – UninformedUser Mar 23 '22 at 04:36

1 Answers1

0

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
Andrew Mayne
  • 1
  • 1
  • 4