Skip to content

Commit

Permalink
global: make search-engine-agnostic
Browse files Browse the repository at this point in the history
* go via `invenio_search.engine` rather than importing elasticsearch
  packages directly
  • Loading branch information
max-moser authored and ntarocco committed Sep 27, 2022
1 parent 5c4c37a commit e7d6c10
Show file tree
Hide file tree
Showing 54 changed files with 608 additions and 536 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/tests-feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ jobs:
requirements-level: [pypi]
cache-service: [redis]
db-service: [postgresql13]
search-service: [elasticsearch7]
search-service: [opensearch1,elasticsearch7]
include:
- db-service: postgresql13
DB_EXTRAS: "postgresql"

- search-service: opensearch1
SEARCH_EXTRAS: "opensearch1"

- search-service: elasticsearch7
SEARCH_EXTRAS: "elasticsearch7"

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ jobs:
python-version: [3.7, 3.8, 3.9]
requirements-level: [pypi]
db-service: [postgresql10, postgresql13]
search-service: [elasticsearch7]
search-service: [opensearch1,elasticsearch7]
exclude:
- python-version: 3.7
db-service: postgresql13

include:
- search-service: opensearch1
SEARCH_EXTRAS: "opensearch1"

- search-service: elasticsearch7
SEARCH_EXTRAS: "elasticsearch7"

Expand Down
2 changes: 1 addition & 1 deletion gen-migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fi
parent_id=$1
message=$2

eval "$(docker-services-cli up --db ${DB:-postgresql} --search ${ES:-elasticsearch} --mq ${CACHE:-redis} --env)"
eval "$(docker-services-cli up --db ${DB:-postgresql} --search ${ES:-opensearch} --mq ${CACHE:-redis} --env)"
export INVENIO_SQLALCHEMY_DATABASE_URI=${SQLALCHEMY_DATABASE_URI}
invenio db drop --yes-i-know
invenio alembic upgrade
Expand Down
4 changes: 2 additions & 2 deletions invenio_vocabularies/contrib/affiliations/affiliations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

"""Vocabulary affiliations."""

from invenio_records.dumpers import ElasticsearchDumper
from invenio_records.dumpers import SearchDumper
from invenio_records.dumpers.indexedat import IndexedAtDumperExt
from invenio_records_resources.factories.factory import RecordTypeFactory

Expand All @@ -28,7 +28,7 @@
},
schema_version="1.0.0",
schema_path="local://affiliations/affiliation-v1.0.0.json",
record_dumper=ElasticsearchDumper(
record_dumper=SearchDumper(
extensions=[
IndexedAtDumperExt(),
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 CERN.
# Copyright (C) 2022 CERN.
# Copyright (C) 2022 Northwestern University.
#
# Invenio-Vocabularies is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see LICENSE file for more
# details.

"""Affiliations Elasticsearch v6 mappings."""
"""Affiliations search mappings."""
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2022 CERN.
#
# Invenio-Vocabularies is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see LICENSE file for more
# details.

"""Affiliations OpenSearch v1 mappings."""
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"mappings": {
"dynamic": "strict",
"properties": {
"$schema": {
"type": "keyword",
"index": "false"
},
"created": {
"type": "date"
},
"updated": {
"type": "date"
},
"indexed_at": {
"type": "date"
},
"uuid": {
"type": "keyword"
},
"version_id": {
"type": "integer"
},
"id": {
"type": "keyword"
},
"name_sort": {
"type": "keyword"
},
"name": {
"type": "text",
"copy_to": "name_sort",
"fields": {
"suggest": {
"type": "search_as_you_type"
}
}
},
"acronym": {
"type": "text",
"fields": {
"suggest": {
"type": "search_as_you_type"
}
}
},
"identifiers": {
"properties": {
"identifier": {
"type": "keyword"
},
"scheme": {
"type": "keyword"
}
}
},
"pid": {
"type": "object",
"properties": {
"pk": {
"type": "integer"
},
"pid_type": {
"type": "keyword"
},
"obj_type": {
"type": "keyword"
},
"status": {
"type": "keyword"
}
}
},
"title": {
"type": "object",
"dynamic": true,
"properties": {
"en": {
"type": "search_as_you_type"
}
}
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# modify it under the terms of the MIT License; see LICENSE file for more
# details.

"""Affiliations Elasticsearch 7 mappings."""
"""Affiliations Elasticsearch v7 mappings."""
4 changes: 2 additions & 2 deletions invenio_vocabularies/contrib/awards/awards.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
ResponseHandler,
)
from invenio_db import db
from invenio_records.dumpers import ElasticsearchDumper
from invenio_records.dumpers import SearchDumper
from invenio_records.dumpers.indexedat import IndexedAtDumperExt
from invenio_records.dumpers.relations import RelationDumperExt
from invenio_records.systemfields import RelationsField
Expand Down Expand Up @@ -49,7 +49,7 @@
# service level when create({}), see records-resources.
"pid": db.Column(db.String, unique=True),
},
record_dumper=ElasticsearchDumper(
record_dumper=SearchDumper(
model_fields={"pid": ("id", str)},
extensions=[
RelationDumperExt("relations"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# modify it under the terms of the MIT License; see LICENSE file for more
# details.

"""Awards Elasticsearch 6 mappings."""
"""Awards search mappings."""
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# modify it under the terms of the MIT License; see LICENSE file for more
# details.

"""Funders Elasticsearch v6 mappings."""
"""Awards OpenSearch v1 mappings."""
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"mappings": {
"dynamic": "strict",
"properties": {
"$schema": {
"type": "keyword",
"index": "false"
},
"created": {
"type": "date"
},
"updated": {
"type": "date"
},
"indexed_at": {
"type": "date"
},
"uuid": {
"type": "keyword"
},
"version_id": {
"type": "integer"
},
"identifiers": {
"properties": {
"identifier": {
"type": "keyword"
},
"scheme": {
"type": "keyword"
}
}
},
"id": {
"type": "keyword"
},
"title": {
"type": "object",
"dynamic": true,
"properties": {
"en": {
"type": "search_as_you_type"
}
}
},
"number": {
"type": "keyword"
},
"acronym": {
"type": "keyword"
},
"funder": {
"type": "object",
"properties": {
"@v": {
"type": "keyword"
},
"id": {
"type": "keyword"
},
"name": {
"type": "text"
}
}
}
}
}
}
Loading

0 comments on commit e7d6c10

Please sign in to comment.