Hi,
in the query examples at https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual/MWAPI#Find... , the way to search for "cheese" is <code> bd:serviceParam mwapi:search "cheese" . </code>
What if the search string I want to use is a composite, e.g. "goat cheese"?
I have tried single quotes, escaping the quotes, and replacing the spaces with plus signs, but non of these would guarantee that the search results only contain the search string (plus some grammatical variations) and not things like "This cheese was made from goat milk".
Any pointers would be appreciated.
Thanks,
Daniel
Underscore instead of space?
On Fri, Jul 13, 2018 at 11:11 AM Daniel Mietchen via Wikitech-l < wikitech-l@lists.wikimedia.org> wrote:
Hi,
in the query examples at
https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual/MWAPI#Find... , the way to search for "cheese" is
<code> bd:serviceParam mwapi:search "cheese" . </code>
What if the search string I want to use is a composite, e.g. "goat cheese"?
I have tried single quotes, escaping the quotes, and replacing the spaces with plus signs, but non of these would guarantee that the search results only contain the search string (plus some grammatical variations) and not things like "This cheese was made from goat milk".
Any pointers would be appreciated.
Thanks,
Daniel
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Hi!
in the query examples at https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual/MWAPI#Find... , the way to search for "cheese" is
<code> bd:serviceParam mwapi:search "cheese" . </code>
What if the search string I want to use is a composite, e.g. "goat cheese"?
So, that depends on what you're looking for. This specific endpoint (EntitySearch) is wbsearchentities API (https://www.mediawiki.org/wiki/Wikibase/API#wbsearchentities), i.e. prefix search. I don't think it has an option for "exact match", however it would match only the prefix, i.e. it won't match "This cheese was made from goat milk". However, if you want to use full-text search instead, you may need to use phrase search to capture only exact phrase. In that case you probably should write the parameter as:
bd:serviceParam mwapi:search ""goat cheese"" .
Probably something like this: http://tinyurl.com/y9fdva5w
Thanks, Stas - this works well so far. Daniel
On Fri, Jul 13, 2018 at 8:37 PM, Stas Malyshev smalyshev@wikimedia.org wrote:
Hi!
in the query examples at https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual/MWAPI#Find... , the way to search for "cheese" is
<code> bd:serviceParam mwapi:search "cheese" . </code>
What if the search string I want to use is a composite, e.g. "goat cheese"?
So, that depends on what you're looking for. This specific endpoint (EntitySearch) is wbsearchentities API (https://www.mediawiki.org/wiki/Wikibase/API#wbsearchentities), i.e. prefix search. I don't think it has an option for "exact match", however it would match only the prefix, i.e. it won't match "This cheese was made from goat milk". However, if you want to use full-text search instead, you may need to use phrase search to capture only exact phrase. In that case you probably should write the parameter as:
bd:serviceParam mwapi:search "\"goat cheese\"" .
Probably something like this: http://tinyurl.com/y9fdva5w
-- Stas Malyshev smalyshev@wikimedia.org
wikitech-l@lists.wikimedia.org