| 0 |
## [Developer Center](https://openlibrary.org/developers) → [APIs](https://openlibrary.org/developers/api) → Search API |
0 |
## [Developer Center](https://openlibrary.org/developers) → [APIs](https://openlibrary.org/developers/api) → Search API |
|
|
1 |
|
|
|
2 |
**URL:** https://openlibrary.org/search.json |
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
<table> |
|
|
7 |
<thead> |
|
|
8 |
<tr> |
|
|
9 |
<th width=100><b>Parameter</b></th> |
|
|
10 |
<th><b>Description</b></th> |
|
|
11 |
</tr> |
|
|
12 |
</thead> |
|
|
13 |
<tbody> |
|
|
14 |
<tr> |
|
|
15 |
<th><code>q<code></th> |
|
|
16 |
<td>The solr query. See <a href="/search/howto">Search HowTo</a> for sample queries</td> |
|
|
17 |
</tr> |
|
|
18 |
<tr> |
|
|
19 |
<th><code>fields</code></th> |
|
|
20 |
<td> |
|
|
21 |
|
|
|
22 |
The <a href="https://github.com/internetarchive/openlibrary/blob/b4afa14b0981ae1785c26c71908af99b879fa975/openlibrary/plugins/worksearch/schemes/works.py#L38-L91">fields</a> to get back from solr. The special value <code>*</code> may be provided to fetch all fields (however this will result in an expensive response, please use sparingly). |
|
|
23 |
<br /> |
|
|
24 |
To fetch availability data from archive.org, add the special value, <code>availability</code>. Example: <a href="/search.json?q=harry%20potter&fields=*,availability&limit=1">/search.json?q=harry%20potter&fields=*,availability&limit=1</a>. This will fetch the availability data of the first item in the `ia` field. |
|
|
25 |
</tr> |
|
|
26 |
<tr> |
|
|
27 |
<th><code>sort<code></th> |
|
|
28 |
<td>You can sort the results by various facets such as <code>new</code>, <code>old</code>, <code>random</code>, or <code>key</code> (which sorts as a string, not as the number stored in the string). For a complete list of sorts facets look <a href="https://github.com/internetarchive/openlibrary/blob/b4afa14b0981ae1785c26c71908af99b879fa975/openlibrary/plugins/worksearch/schemes/works.py#L119-L153">here</a> (this link goes to a specific commit, be sure to look at the latest one for changes). The default is to sort by relevance. |
|
|
29 |
</tr> |
|
|
30 |
<tr> |
|
|
31 |
<th><code>lang<code></th> |
|
|
32 |
<td>The users language as a two letter (ISO 639-1) language code. This influences but doesn't exclude search results. For example setting this to <code>fr</code> will prefer/display the French edition of a given work, but will still match works that don't have French editions. Adding <code>language:fre</code> on the other hand to the search query <i>will</i> exclude results that don't have a French edition. |
|
|
33 |
</tr> |
|
|
34 |
<tr> |
|
|
35 |
<th><code>offset</code> / <code>limit<code></th> |
|
|
36 |
<td>Use for pagination.</td> |
|
|
37 |
</tr> |
|
|
38 |
<tr> |
|
|
39 |
<th><code>page</code> / <code>limit<code></th> |
|
|
40 |
<td>Use for pagination, with <code>limit</code> corresponding to the page size. Note <code>page</code> starts at 1.</td> |
|
|
41 |
</tr> |
|
|
42 |
</table> |
|
|
43 |
|
|
|
44 |
|
|
|
45 |
## Overview |
| 1 |
|
1 |
|
| ... |
|
... |
|
| 24 |
|
24 |
|
| 25 |
## URL Parameters |
|
|
| 26 |
|
70 |
|
| 27 |
<table> |
|
|
| 28 |
<thead> |
|
|
| 29 |
<tr> |
|
|
| 30 |
<th width=100><b>Parameter</b></th> |
|
|
| 31 |
<th><b>Description</b></th> |
|
|
| 32 |
</tr> |
|
|
| 33 |
</thead> |
|
|
| 34 |
<tbody> |
|
|
| 35 |
<tr> |
|
|
| 36 |
<th><code>q<code></th> |
|
|
| 37 |
<td>The solr query. See <a href="/search/howto">Search HowTo</a> for sample queries</td> |
|
|
| 38 |
</tr> |
|
|
| 39 |
<tr> |
|
|
| 40 |
<th><code>fields</code></th> |
|
|
| 41 |
<td> |
|
|
| 42 |
|
|
|
| 43 |
The fields to get back from solr. Use the special value <code>*</code> to get all fields (although be prepared for a very large response!). |
|
|
| 44 |
<br /> |
|
|
| 45 |
To fetch availability data from archive.org, add the special value, <code>availability</code>. Example: <a href="/search.json?q=harry%20potter&fields=*,availability&limit=1">/search.json?q=harry%20potter&fields=*,availability&limit=1</a>. This will fetch the availability data of the first item in the `ia` field. |
|
|
| 46 |
</tr> |
|
|
| 47 |
<tr> |
|
|
| 48 |
<th><code>sort<code></th> |
|
|
| 49 |
<td>You can sort the results by various facets such as <code>new</code>, <code>old</code>, <code>random</code>, or <code>key</code> (which sorts as a string, not as the number stored in the string). For a complete list of sorts facets look <a href="https://github.com/internetarchive/openlibrary/blob/b4afa14b0981ae1785c26c71908af99b879fa975/openlibrary/plugins/worksearch/schemes/works.py#L119-L153">here</a> (this link goes to a specific commit, be sure to look at the latest one for changes). The default is to sort by relevance. |
|
|
| 50 |
</tr> |
|
|
| 51 |
<tr> |
|
|
| 52 |
<th><code>lang<code></th> |
|
|
| 53 |
<td>The users language as a two letter (ISO 639-1) language code. This influences but doesn't exclude search results. For example setting this to <code>fr</code> will prefer/display the French edition of a given work, but will still match works that don't have French editions. Adding <code>language:fre</code> on the other hand to the search query <i>will</i> exclude results that don't have a French edition. |
|
|
| 54 |
</tr> |
|
|
| 55 |
<tr> |
|
|
| 56 |
<th><code>offset</code> / <code>limit<code></th> |
|
|
| 57 |
<td>Use for pagination.</td> |
|
|
| 58 |
</tr> |
|
|
| 59 |
<tr> |
|
|
| 60 |
<th><code>page</code> / <code>limit<code></th> |
|
|
| 61 |
<td>Use for pagination, with <code>limit</code> corresponding to the page size. Note <code>page</code> starts at 1.</td> |
|
|
| 62 |
</tr> |
|
|
| 63 |
</table> |
|
|
| 64 |
|
64 |
|
| ... |
|
... |
|
| 183 |
- You can see the exact boosting logic in the code here: https://github.com/internetarchive/openlibrary/blob/dc49fddb78a3cb25138922790ddd6a5dd2b5741c/openlibrary/plugins/worksearch/schemes/works.py#L439-L448 |
183 |
- You can see the exact boosting logic in the code here: https://github.com/internetarchive/openlibrary/blob/dc49fddb78a3cb25138922790ddd6a5dd2b5741c/openlibrary/plugins/worksearch/schemes/works.py#L439-L448 |
|