query-9ddc2b8ddb2fd48c2729a3f644be5f46
Searching for multiple text strings in one query 13:31, 11 August 2020 (UTC)) talk (Trilotat: you've been amazing. Dipsacus fullonumI've got a long list of faults (my spouse reminds me of this often! haha) and would like to search for articles that contain these terms, but I don't want to search each string individually. I can manipulate the results to add my list, but my question is can someone provide the structure. Example, how can I search for articles that contain Fault Atacama OR Fault Wellington? If I search for fault atacama (WITHOUT quotes), I get three results. If I search for fault wellington, I get 10 results. I'd like this requested query to provide all 13 in the result. Peculiar, I know, but I can extend your query to include many other faults so I can then work on the results. If you have to filter the query to make it work, please consider Q13442814 and Q193842. Thanks so much for your time; I have been asking for a lot lately and @
Use at
- https://query.wikidata.org/sparql
PREFIX mwapi: <http://wikiba.se/ontology#>
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 ?item ?itemLabel ?instance_of ?instance_ofLabel
WHERE
{
VALUES ?search_string {
"Atacama fault"
"Wellington fault"
"it's my fault honey"
}
SERVICE wikibase:mwapi
{
bd:serviceParam wikibase:api "Search" .
bd:serviceParam wikibase:endpoint "www.wikidata.org" .
bd:serviceParam mwapi:srnamespace "0" .
bd:serviceParam mwapi:srsearch ?search_string .
?title wikibase:apiOutput mwapi:title .
}
BIND( URI(CONCAT(str(wd:),?title)) as ?item)
OPTIONAL { ?item wdt:P31 ?instance_of }
# MINUS { ?item wdt:P31 wd:Q13442814 } # no articles
# ?item wdt:P31 wd:Q47089 #only faults
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}