api-docs icon indicating copy to clipboard operation
api-docs copied to clipboard

hasimage not working properly

Open ashkan90 opened this issue 7 years ago • 9 comments

https://api.harvardartmuseums.org/object&hasimage=1&gallery=1320

then it's returning a lot data but all data don't have image "images": [], "primaryimageurl": null,

that's not what i excepted. How can i handle this problem ?

ashkan90 avatar Jan 18 '19 12:01 ashkan90

The hasimages parameter will find objects that have images regardless of the copyright status. We strip out image data if there are copyright issues hence the empty array and null values. You need to add the following parameter: q=imagepermissionlevel:0. This will reduce your data set to objects with images that have no known copyright issues.

See also related comments in https://github.com/harvardartmuseums/api-docs/issues/6#issuecomment-442618209.

jeffsteward avatar Jan 18 '19 21:01 jeffsteward

I'm hitting this issue every few images even with a query string that contains the params mentioned in the fix threads: imagepermissionlevel=0&hasimage=1.

Ex:

https://api.harvardartmuseums.org/object?page=1571&apikey=[REDACTED]&size=1&hasimage=1&imagepermissionlevel=0&classification=Paintings&people.role=Artist

peterjcaulfield avatar Mar 21 '20 01:03 peterjcaulfield

You must use the q parameter whenever you are querying a field that is not named in the parameter list. In your case change imagepermissionlevel=0&hasimage=1 to q=imagepermissionlevel:0&hasimage=1.

jeffsteward avatar Mar 23 '20 16:03 jeffsteward

@jeffsteward Great thanks for clarifying! All looks good now 👍

peterjcaulfield avatar Mar 27 '20 13:03 peterjcaulfield

I'm still getting this issue even with the permission level parameter? Would love another set of eyes on it: https://api.harvardartmuseums.org/object?apikey=[mykey]&hasimage=1&sort=random&person=any&primaryimageul=true&keyword=sun&q=imagepermissionlevel%3A0&page=2

heatherca avatar May 01 '20 19:05 heatherca

@heatherca Some of the parameters in your query won't work. primaryimageurl isn't a named parameter. The only way to query fields that are not in [the list of named parameters] (https://github.com/harvardartmuseums/api-docs/blob/master/sections/object.md#get-objects ) is via the q parameter. Here's a reformatted version of your query.

https://api.harvardartmuseums.org/object?apikey=[mykey]&hasimage=1&sort=random&q=imagepermissionlevel:0 AND primaryimageurl:*&person=any&keyword=sun

That being said, I think you found a bug in our query logic. When I run the reformatted query I get more records than expected. I need to investigate further.

jeffsteward avatar May 05 '20 20:05 jeffsteward

That was my bad I was trying to throw more things onto to get it to work. I think the main issue was that q was being overridden by keyword. When I commented out keyword in my call all the results would have the correct imagepermissionlevel:0. I ended up using title instead of keyword which didn't have the same issue.

Would still get imagepermissionlevel not equal to zero: https://api.harvardartmuseums.org/object?apikey=[mykey]&hasimage=1&sort=random&person=any&keyword=sun&q=imagepermissionlevel:0

This worked: https://api.harvardartmuseums.org/object?apikey=[mykey]&hasimage=1&sort=random&person=any&title=sun&q=imagepermissionlevel:0

heatherca avatar May 05 '20 20:05 heatherca

Thanks for the additional info. All signs point to a bad implementation of the keyword parameter. I'm going to log a new issue.

jeffsteward avatar May 05 '20 21:05 jeffsteward