Commit dd3ac26b authored by Anders Johansson's avatar Anders Johansson

Limit search to specific libraries, by default private library.

Restrict search to private library by default but allow specific
library or "all" through new library parameter to the search interface.

Fixes #44
parent a93b24fe
......@@ -86,4 +86,8 @@ param as in the ``items`` endpoint. For example:
You can supply an argument to the ``method`` parameter to change the
quicksearch version, either ``titleCreatorYear`` (the default),
``everything`` or ``fields``.
``everything`` or ``fields``. By default, search is done only in the
private library, but the parameter ``library`` allows you to provide a
specific libraryID to use, or the string ``all`` for searching in all
libraries.
......@@ -348,6 +348,11 @@ function searchEndpoint(options) {
const query = cleanQuery(options.query);
if (query.q) {
let search = buildSearch(new Zotero.Search(), query.q, query.method);
if (!query.library) {
search.libraryID = Zotero.Libraries.userLibraryID;
} else if (query.library !== "all") {
search.libraryID = query.library;
}
return runSearch(search, Zotero).then((items)=>{
return buildResponse(items, query.format, query.style);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment