WikibaseIntegrator icon indicating copy to clipboard operation
WikibaseIntegrator copied to clipboard

Support query in a helper function

Open dpriskorn opened this issue 3 years ago • 8 comments

https://www.wikidata.org/w/api.php?action=help&modules=query that module enables search using the cirrussearch extensions on Wikidata, see https://www.mediawiki.org/wiki/Help:Extension:WikibaseCirrusSearch

It is much more powerful than wbsearchentities it seems.

Example search is here: https://www.wikidata.org/w/api.php?format=json&action=query&list=search&srprop=&srlimit=10&srsearch=-haswbstatement:P31=Q13442814%20-haswbstatement:P31=Q5633421%20breast%20cancer

dpriskorn avatar Sep 11 '21 14:09 dpriskorn

Hello @dpriskorn Thank you for this issue. It's a really good idea.

I wonder how to create this function to be easily understandable by the user.

  • Allow to pass Claim as parameter
  • Use python dict
  • Use string

I started with the first one, but there is so much different case (has/hasnot, AND/OR, etc.), so i'm afraid the user will be lost.

LeMyst avatar Sep 12 '21 19:09 LeMyst

I'm thinking pass a string for now and a limit will suffice. We can just link to the documentation. 😃

dpriskorn avatar Sep 20 '21 18:09 dpriskorn

There is probably no good way to support CirrusSearch without it being too complicated.

LeMyst avatar Jan 23 '22 22:01 LeMyst

I am definitely interested in this functionality and would be happy to have a simple string as the parameter.

For instance, the documentation gives the example of kitten haswbstatement:P31=Q3305213. I was hoping I could do

wbi_helpers.search_entities("kitten haswbstatement:P31=Q3305213")

But this confusingly returns ['Q3305213'] (the same as the property value).

While a more complex method taking dict or Claim could be implemented, a string seems good enough for the web UI and it's good enough for my use cases.

Thunderforge avatar Oct 11 '22 02:10 Thunderforge

@dpriskorn @Thunderforge

I've created the #436 to add a call to the query/search API endpoint. But I can't really process the data because it only return "page" and not "Item" or "Lexeme".

It's good for you?

LeMyst avatar Oct 11 '22 21:10 LeMyst

I would like it documented also with a Wikibase cirrus search example also. I can submit a patch if you would like 😀

dpriskorn avatar Oct 12 '22 05:10 dpriskorn

I would like it documented also with a Wikibase cirrus search example also. I can submit a patch if you would like 😀

With pleasure 😄

LeMyst avatar Oct 12 '22 05:10 LeMyst

@LeMyst This works great for my use cases. Thank you!

Thunderforge avatar Oct 15 '22 23:10 Thunderforge