Skip to content
Collections

Collections

After this page you can make your searches stay within a SciX collection, such as astronomy, without adding the condition every time, and you will know which searches it leaves alone.

SciX covers several disciplines, which it calls collections (the database field): astronomy, physics, earthscience and others. By default scixplorer searches all of them.

Set a default collection

from scixplorer import Document, config, search

config.collection = "astronomy"
search.to_solr(Document.year == 2020)
# -> year:2020 AND database:"astronomy"

Give a list for several collections:

config.collection = ["astronomy", "physics"]
search.to_solr(Document.year == 2020)
# -> year:2020 AND database:("astronomy" OR "physics")

None (the default), or a blank name, means all collections. Names are not checked against the collections SciX has. A value that is neither a string nor a sequence of strings raises TypeError when a search is planned.

When it is applied

The collection is added as a final top-level “and” condition to every open document search: one that does not already say which collection it wants, or which documents it wants. It is not applied when the search:

The search…ExampleBecause
names a collection itselfDocument.database == "physics", Document.collection == "physics", or raw Solr containing database: or collection:your own choice wins
asks for specific documentsa top-level == or in_() on bibcode, scix_id, id, identifier, doi or alternate_bibcodeyou know which documents you want, whatever their collection
asks for a library’s documentsa top-level Document.in_(library)the same
config.collection = "astronomy"
search.to_solr(Document.bibcode == "2015GeoRL..42..264E")
# -> bibcode:"2015GeoRL..42..264E"
search.to_solr(Document.database == "earthscience")
# -> database:"earthscience"

“Top-level” means joined to the rest of the search with &. A bibcode inside | does not name the documents of the whole search, so the collection still applies:

search.to_solr((Document.bibcode == "2015GeoRL..42..264E") | (Document.year == 2020))
# -> (bibcode:"2015GeoRL..42..264E" OR year:2020) AND database:"astronomy"

Because Document.get(bibcode=...) and the requests that lazy loading sends name documents by identifier, they are never limited by the default collection.

The setting applies only to document searches. Journals, affiliations, vocabularies and libraries are not affected.

explain() says whether the collection was applied, and why not:

query = (
    Document
    .select()
    .where(Document.year == 2020)
)
print(query.explain())
# -> limited to collection 'astronomy' (scixplorer.config.collection): database:"astronomy" is added

The collection does not count as narrowing a search for the purpose of the whole-index guard: a search that SciX would otherwise answer with every document is refused even with a collection set.