Elasticsearch#
WIP - auto-generated documentation. This can be used to imply the index document structures, but it is recommended to refer to the Elasticsearch instance directly.
Objects used to interface with Elasticsearch implementations.
- class app.domain.references.models.es.AnnotationDocument(meta: Dict[str, Any] | None = None, **kwargs: Any)[source]#
Bases:
GenericNestedDocumentPersistence model for useful annotation fields in Elasticsearch.
- class app.domain.references.models.es.EnhancementContentDocument(meta: Dict[str, Any] | None = None, **kwargs: Any)[source]#
Bases:
GenericNestedDocumentPersistence model for enhancement content in Elasticsearch.
We define anything we want to explicitly index here and map as dynamic in the parent document.
- annotations: list[AnnotationDocument] | None = InstrumentedField[annotations][source]#
- clean() None[source]#
Automatically called when saving a document.
We utilise to provide a final barrier to prevent RAW enhancements being indexed.
- enhancement_type: EnhancementType = InstrumentedField[enhancement_type][source]#
- class app.domain.references.models.es.EnhancementDocument(meta: Dict[str, Any] | None = None, **kwargs: Any)[source]#
Bases:
GenericNestedDocumentPersistence model for enhancements in Elasticsearch.
- content: EnhancementContentDocument = InstrumentedField[content][source]#
- classmethod from_domain(domain_obj: Enhancement) Self[source]#
Create a persistence model from a domain model.
- to_domain(reference_id: UUID) Enhancement[source]#
Create a domain model from this persistence model.
- visibility: Visibility = InstrumentedField[visibility][source]#
- class app.domain.references.models.es.ExternalIdentifierDocument(meta: Dict[str, Any] | None = None, **kwargs: Any)[source]#
Bases:
GenericNestedDocumentPersistence model for external identifiers in Elasticsearch.
- classmethod from_domain(domain_obj: LinkedExternalIdentifier) Self[source]#
Create a persistence model from a domain ExternalIdentifier object.
- identifier_type: ExternalIdentifierType = InstrumentedField[identifier_type][source]#
- to_domain(reference_id: UUID) LinkedExternalIdentifier[source]#
Convert the persistence model into a Domain ExternalIdentifier object.
- class app.domain.references.models.es.ReferenceDocument(meta: Dict[str, Any] | None = None, **kwargs: Any)[source]#
Bases:
GenericESPersistence[Reference],ReferenceSearchFieldsMixinLean persistence model for references in Elasticsearch.
This document stores only the fields needed for search operations: - visibility and duplicate_determination for filtering - search fields (title, abstract, authors, etc.) from ReferenceSearchFieldsMixin
Full reference data (including identifiers) is stored in PostgreSQL and hydrated from there when needed. Identifier lookups are done via PostgreSQL, not ES. Nested structures (identifiers, enhancements) are preserved only in the RobotAutomationPercolationDocument for percolation queries.
- duplicate_determination: DuplicateDetermination | None = InstrumentedField[duplicate_determination][source]#
- classmethod from_domain(domain_obj: Reference) Self[source]#
Create a persistence model from a domain model.
- to_domain() Reference[source]#
Create a minimal domain model from this persistence model.
Since ES is now search-only, full hydration should be done from PostgreSQL. This returns a minimal Reference with only the ID and visibility.
- visibility: Visibility = InstrumentedField[visibility][source]#
- class app.domain.references.models.es.ReferenceDomainMixin(meta: Dict[str, Any] | None = None, **kwargs: Any)[source]#
Bases:
InnerDocMapping of Reference domain model to Elasticsearch document.
- duplicate_determination: DuplicateDetermination | None = InstrumentedField[duplicate_determination][source]#
- enhancements: list[EnhancementDocument] = InstrumentedField[enhancements][source]#
- classmethod from_domain(reference: Reference) Self[source]#
Create a ReferenceDomainMixin from a Reference domain model.
- identifiers: list[ExternalIdentifierDocument] = InstrumentedField[identifiers][source]#
- visibility: Visibility = InstrumentedField[visibility][source]#
- class app.domain.references.models.es.ReferenceSearchFieldsMixin(meta: Dict[str, Any] | None = None, **kwargs: Any)[source]#
Bases:
InnerDocMixin to project Reference fields relevant to various search strategies.
Currently this holds fields for identifying candidate canonicals during deduplication and for searching references by query.
- annotations: list[str] | None = InstrumentedField[annotations][source]#
Every
trueannotation on the reference.These are in format
<scheme>[/<label>].Examples:
classification:taxonomy:Outcomes/Strokeclassification:taxonomy:Intervention/Climate policy instrumentsinclusion:destiny(No label)
- authors: list[str] | None = InstrumentedField[authors][source]#
The authors of the reference.
These are ordered by:
First author
Middle authors in alphabetical order
Last author
- evaluated_schemes: list[str] | None = InstrumentedField[evaluated_schemes][source]#
Every scheme that has been evaluated for this reference.
Combining this with
annotationsallows you to determine which annotations were evaluated asfalse.Examples:
inclusion:destinyclassifier:taxonomy:Outcomes
- classmethod from_domain(reference: Reference) Self[source]#
Create the ES ReferenceDeduplicationMixin.
- classmethod from_projection(projection: ReferenceSearchFields) Self[source]#
Create a ReferenceCandidateCanonicalMixin from the search projection.
- inclusion_destiny: float | None = InstrumentedField[inclusion_destiny][source]#
The destiny inclusion score for this reference.
This is used to apply custom thresholds for inclusion. If you just want to know if the reference was included per the default threshold, check for
inclusion:destinyinannotations.
- publication_date: date | None = InstrumentedField[publication_date][source]#
The publication date of the reference.
- class app.domain.references.models.es.RobotAutomationPercolationDocument(meta: Dict[str, Any] | None = None, **kwargs: Any)[source]#
Bases:
GenericESPersistence[RobotAutomation]Persistence model for robot automation percolation in Elasticsearch.
This model serves two purposes in order to fully define the index: a persistence layer for queries that dictate robot automation, and a percolator layer to convert domain models to queryable documents that run against said queries.
- changeset: ReferenceDomainMixin | None = InstrumentedField[changeset][source]#
- classmethod from_domain(domain_obj: RobotAutomation) Self[source]#
Create a percolator query from a domain model.
- classmethod percolatable_document_from_domain(percolatable: ReferenceWithChangeset) Self[source]#
Create a percolatable document from a domain model.
- Parameters:
percolatable (ReferenceWithChangeset) – The percolatable document to convert.
- Returns:
The persistence model.
- Return type:
- reference: ReferenceDomainMixin | None = InstrumentedField[reference][source]#
- to_domain() RobotAutomation[source]#
Create a domain model from this persistence model.