Searching for works by an author fails

Bug #523316 reported by Edward Betts
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Open Library
Fix Released
Critical
Anand Chitipothu

Bug Description

I should be able to use the API to search for all works by an author.

I would expect this URLs to return a list of works by William Shakespeare:

http://openlibrary.org/query.json?type=/type/work&authors.author=/a/OL9388A

http://upstream.openlibrary.org/query.json?type=/type/work&authors.author=/a/OL9388A

They don't give an error, I just get an empty list.

It doesn't work because they're linked by an embedded type.

This would be very useful when working with the data in the database.

Changed in openlibrary:
importance: Undecided → Critical
status: New → Confirmed
assignee: nobody → Anand Chitipothu (anandology)
importance: Critical → High
Revision history for this message
Anand Chitipothu (anandology) wrote : Re: [Bug 523316] [NEW] Searching for works by an author fails

On 17-Feb-10, at 11:00 PM, Edward Betts wrote:

> Public bug reported:
>
> I should be able to use the API to search for all works by an author.
>
> I would expect this URLs to return a list of works by William
> Shakespeare:
>
> http://openlibrary.org/query.json?type=/type/work&authors.author=/a/OL9388A
>
> http://upstream.openlibrary.org/query.json?type=/type/work&authors.author=/a/OL9388A
>
> They don't give an error, I just get an empty list.
>
> It doesn't work because they're linked by an embedded type.
>
> This would be very useful when working with the data in the database.

Use this instead:

http://upstream.openlibrary.org/query.json?query={"type": "/type/
work", "authors": {"author": {"key": "/authors/OL9388A"}}}

Revision history for this message
Edward Betts (edwardbetts) wrote :

That includes duplicates:

http://upstream.openlibrary.org/query.json?query={%22limit%22:500,%22type%22:%20%22/type/work%22,%20%22authors%22:%20{%22author%22:%20{%22key%22:%20%22/authors/OL32983A%22}}}

/works/OL495477W appears more than one

George (george-archive)
Changed in openlibrary:
milestone: none → general-bucket
Revision history for this message
Edward Betts (edwardbetts) wrote :

Also some searches are missing results:

from openlibrary.api import OpenLibrary, Reference
ol = OpenLibrary("http://openlibrary.org")
q = {'type': '/type/work', 'authors': {'author': Reference('/a/OL2837555A')}}
print ol.query(q)
print ol.get('/works/OL8493302W')['authors']

Gives:

[]
[{'type': '/type/author_role', 'author': <ref: u'/a/OL2837555A'>}]

Changed in openlibrary:
milestone: general-bucket → upstream-to-www
Revision history for this message
George (george-archive) wrote :

Bumping this in priority (High -> Critical) since it's a blocker for Edward.

Changed in openlibrary:
importance: High → Critical
Revision history for this message
Anand Chitipothu (anandology) wrote :

Started reindexing the work_ref table.

  3.4% ( 479397/14091822) [=> ] ETA 25:15:14

Changed in openlibrary:
status: Confirmed → In Progress
Revision history for this message
Anand Chitipothu (anandology) wrote :

Finished reindexing the work_ref table. Queries should work now.

Edward, please verify and close this bug.

Revision history for this message
Edward Betts (edwardbetts) wrote :

Anand, I ran my test from a previous bug comment and I get the same results, so the bug isn't fixed.

Revision history for this message
Edward Betts (edwardbetts) wrote :

I rewrote my example, now it works:

from openlibrary.api import OpenLibrary, Reference
ol = OpenLibrary("http://openlibrary.org")
q = {'type': '/type/work', 'authors': {'author': {'key': '/a/OL2837555A'}}}
print ol.query(q)
print ol.get('/works/OL8493302W')['authors']

Output is:

[<ref: u'/works/OL8493303W'>, <ref: u'/works/OL8493302W'>]

So I guess it is fixed.

Changed in openlibrary:
status: In Progress → Fix Released
Revision history for this message
Edward Betts (edwardbetts) wrote :

It is still happening. Here is an example

from openlibrary.api import OpenLibrary
ol = OpenLibrary("http://openlibrary.org")
q = {'type': '/type/work', 'authors': {'author': {'key': '/authors/OL6876811A'}}}
print ol.query(q)
print ol.get('/works/OL15598361W')['authors']

Output is:

[]
[{'type': <ref: u'/type/author_role'>, 'author': <ref: u'/authors/OL6876811A'>}]

Changed in openlibrary:
status: Fix Released → Confirmed
Revision history for this message
George (george-archive) wrote :

Anand - this bug is critical. Please address this week.

Changed in openlibrary:
milestone: upstream-to-www → general-bucket
Revision history for this message
Anand Chitipothu (anandology) wrote :

Noticed that none of the work-author queries are working. There was a NULL == NULL comparison in the SQL query. Fixed it by avoid that case.

$ curl -G http://openlibrary.org/api/things --data-urlencode 'query={"type": "/type/work", "authors": {"author": {"key": "/authors/OL6876811A"}}}'
{"status": "ok", "result": ["/works/OL15598357W", "/works/OL15598361W"]}

Edward: can you please verify?

Changed in openlibrary:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.