OL: Search with Solr

OpenLibrary is using Apache SOLR as search platform.

Solr Server: http://solr:8983/solr/
 Solr Admin: http://solr:8984/solr/admin/
  • To READ/SEARCH an entry:

    curl http://solr:8983/solr/select?q=QUERY

    or using a browser:

    http://solr:8983/solr/select?q=QUERY&cache=false
  • To CREATE/UPDATE an entry:

    curl http://solr:8983/solr/update?commitWithin=10000 -H "Content-Type: text/xml" --data-binary '<add><doc><field name="edition_key">OL7649435M</field><field name="cover_i">405982</field><field name="isbn">9780671525323</field><field name="isbn">0671525328</field><field name="has_fulltext">False</field><field name="author_name">Jeff Noon</field><field name="seed">/books/OL7649435M</field><field name="seed">/works/OL8262577W</field><field name="seed">/authors/OL450487A</field><field name="author_key">OL450487A</field><field name="title">Vurt</field><field name="publish_date">March 1, 1995</field><field name="type">work</field><field name="ebook_count_i">0</field><field name="id_librarything">19214</field><field name="edition_count">1</field><field name="key">/works/OL8262577W</field><field name="id_goodreads">1420154</field><field name="publisher">Audioworks</field><field name="language">eng</field><field name="last_modified_i">1436385710</field><field name="cover_edition_key">OL7649435M</field><field name="publish_year">1995</field><field name="first_publish_year">1995</field><field name="author_facet">OL450487A Jeff Noon</field></doc></add>'
  • To DELETE an entry:

    curl -L 'http://solr:8983/solr/update?commitWithin=10000' -H "Content-Type: text/xml" --data-binary '<delete><query>key:/works/OL17071689W</query></delete>'

    or using a GET:

    curl -l 'http://solr:8983//solr/update?commitWithin=60000&stream.body=%3Cdelete%3E%3Cquery%3Ekey:/works/OL17058137W%3C/query%3E%3C/delete%3E'

    We are using commitWithin=10000 instead of commit=true because the solr server could be busy.

The SOLR response should look like:

<response>
<lst name="responseHeader"><int name="status">0</int><int name="QTime">70</int></lst>
</response>