Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

add depicted item to mwQueryResult #18

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

vanshikaarora
Copy link

Commons app recently added a feature to search for depictions

The MwQueryResult in the library doesn't contain DepictedItem object. This PR adds the model class.

@dbrant
Copy link
Member

dbrant commented Jul 5, 2019

Interesting! Can you give an example API request that would return this structure?

@maskaravivek
Copy link
Contributor

@dbrant
Copy link
Member

dbrant commented Jul 5, 2019

I'm not sure I see what the setlabel API has to do with depicts statements...
What I meant to ask was: can you show me an example API call that will return a MwQueryResult structure with a depictedItem field as seen in this PR?

@maskaravivek
Copy link
Contributor

@vanshikaarora can confirm that.

@dbrant can you make a release without this PR. It would be nice to have other changes available.

@dbrant
Copy link
Member

dbrant commented Jul 5, 2019

@dbrant can you make a release without this PR.

{done}

@vanshikaarora
Copy link
Author

I am extremely sorry @maskaravivek @dbrant it was a major mistake of mine. This is the API https://commons.wikimedia.org/w/api.php?action=help&modules=wbsearchentities

and here is the response for that:

{
    "searchinfo": {
        "search": "abc"
    },
    "search": [],
    "success": 1
}

@maskaravivek
Copy link
Contributor

{
    "searchinfo": {
        "search": "abc"
    },
    "search": [],
    "success": 1
}

@vanshikaarora This response doesn't need to be parsed with MwQueryResult.

@vanshikaarora
Copy link
Author

@markbergsma I have tried this earlier by using

@FormUrlEncoded
    @POST("w/api.php?action=wbsearchentities&format=json&type=item&language=en&uselang=en")
    Observable<DepictsResponse> searchForDepicts(@Field("search") String query, @Field("limit") String limit);

and

return depictsInterface.searchForDepicts(query, String.valueOf(SEARCH_DEPICTS_LIMIT))
                .map(depictsResponse -> {
                    return new DepictedItem(depictsResponse.toString(),"", null, false);
                });

But calling any function on depictsResponse returns no Such Instance Exception.Hence I thought, MwQueryResponse should be the best possible way to work with this

@dbrant
Copy link
Member

dbrant commented Jul 6, 2019

OK, it sounds like your goal is to search for items that contain a depicted string.

In that case I'm still not clear how the wbsearchentities api will let you do that, which is why my question is: Can you construct an API call that does what you're expecting it to do? In other words, construct an API call that returns an actual search result based on a search term?

@dbrant
Copy link
Member

dbrant commented Jul 6, 2019

To be totally clear, here is a constructed API call that, for example, searches for files on Commons that have the string "foo" in their title (click it to see the result):
https://commons.wikimedia.org/w/api.php?format=json&action=query&generator=search&gsrsearch=foo&gsrnamespace=6

Can you now show me an API call that represents what you're trying to do (e.g. return items that depict a certain search term)?

@vanshikaarora
Copy link
Author

Can you now show me an API call that represents what you're trying to do (e.g. return items that depict a certain search term)?

Sure @dbrant here is the commit where I have made changes for the API calls :)

commons-app/apps-android-commons@3886439

@dbrant
Copy link
Member

dbrant commented Jul 6, 2019

I'm afraid it's still very unclear what this is supposed to do.

Based on the commit you linked, you want to make this API call (click it to see the results):
https://www.wikidata.org/w/api.php?action=wbsearchentities&format=json&search=allcategories&language=en&uselang=en&type=item

I'm not seeing anything useful in that response.
If I may restate the question: How does this relate to depictions? What are you expecting this call to return? Can you show me an example API call that returns the results that you want? (i.e. write a URL, like I did above, that returns the results you're looking for)

@vanshikaarora
Copy link
Author

How does this relate to depictions?

As soon as the user types something in "Add depictions for image screen", we search for depictions which are similar to caption entered or similar to the current text entered using the wbsearchentitities api and then display a list of suggestions.

What are you expecting this call to return?

I expect that this call should return similar result for depictions and the response would be similar to this:

{
    "searchinfo": {
        "search": "abc"
    },
    "search": [],
    "success": 1
}

Here is the url:

https://www.wikidata.org/w/api.php?action=wbsearchentities&search=rabbit&format=json&language=en&uselang=en&type=item

@vanshikaarora vanshikaarora force-pushed the depicted_item branch 2 times, most recently from dddf3d0 to 445da7e Compare July 11, 2019 12:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants