Metadata-Version: 2.4
Name: invenio-global-search
Version: 0.4.2
Summary: InvenioRDM module for a Global Search
Home-page: https://github.com/tu-graz-library/invenio-global-search
Author: TU Graz
Author-email: 
License: MIT
Keywords: invenio rdm search
Platform: any
Classifier: Programming Language :: Python :: 3.14
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.12
License-File: LICENSE
License-File: AUTHORS.rst
Requires-Dist: invenio-records-global-search>=0.0.1
Provides-Extra: rdm
Requires-Dist: invenio-rdm-records>=18.0.0; extra == "rdm"
Provides-Extra: lom
Requires-Dist: invenio-records-lom>=0.12.0; extra == "lom"
Provides-Extra: marc21
Requires-Dist: invenio-records-marc21>=0.17.0; extra == "marc21"
Provides-Extra: tests
Requires-Dist: invenio-app>=2.0.0; extra == "tests"
Requires-Dist: invenio-search[opensearch2]>=3.0.0; extra == "tests"
Requires-Dist: pytest-black-ng>=0.4.0; extra == "tests"
Requires-Dist: pytest-invenio>=3.0.0; extra == "tests"
Requires-Dist: ruff>=0.11.9; extra == "tests"
Requires-Dist: ty>=0.0.0a1; extra == "tests"
Requires-Dist: sphinx>=4.5.0; extra == "tests"
Dynamic: license-file

..
    Copyright (C) 2023 Graz University of Technology.

    invenio-global-search is free software; you can redistribute it and/or
    modify it under the terms of the MIT License; see LICENSE file for more
    details.


======================
 invenio-global-search
======================

.. image:: https://github.com/tu-graz-library/invenio-global-search/workflows/CI/badge.svg
        :target: https://github.com/tu-graz-library/invenio-global-search/actions?query=workflow%3ACI

.. image:: https://img.shields.io/github/tag/tu-graz-library/invenio-global-search.svg
        :target: https://github.com/tu-graz-library/invenio-global-search/releases

.. image:: https://img.shields.io/pypi/dm/invenio-global-search.svg
        :target: https://pypi.python.org/pypi/invenio-global-search

.. image:: https://img.shields.io/github/license/tu-graz-library/invenio-global-search.svg
        :target: https://github.com/tu-graz-library/invenio-global-search/blob/master/LICENSE

Dublin Core data model for InvenioRDM


Tests
-----

.. code-block:: console

    uv run ./run-tests.sh


Installation
============

This basic installation of this package::

    uv pip install invenio-global-search

will not give access to any of its features. It is intended to be extended
with the packages needed in a specific Invenio instance.

There are 3 packages handled by ``invenio-global-search``:

- ``rdm-records``
- ``lom`` (OER)
- ``marc21`` (Publications)

To install any of them or all:

- ::

      uv pip install invenio-global-search[rdm]

  This enables the ``rdm-records`` features.

- ::

      uv pip install invenio-global-search[rdm, marc21, lom]

  This enables all the features of the package.


Configuration
=============

Add the following code blocks to the ``invenio.cfg`` file.


Components
----------

If all packages mentioned above are installed, simply add:

.. code-block:: python

    from invenio_rdm_records.services.components import DefaultRecordsComponents
    from invenio_global_search.components import (
        LOMToGlobalSearchComponent,
        Marc21ToGlobalSearchComponent,
        RDMToGlobalSearchComponent,
    )

    from invenio_rdm_records.services.components import (
        DefaultRecordsComponents as RDMDefaultRecordsComponents,
    )
    from invenio_records_lom.services.components import (
        DefaultRecordsComponents as LOMDefaultRecordsComponents,
    )
    from invenio_records_marc21.services.components import (
        DefaultRecordsComponents as Marc21DefaultRecordsComponents,
    )


    RDM_RECORDS_SERVICE_COMPONENTS = RDMDefaultRecordsComponents + [
        RDMToGlobalSearchComponent
    ]
    LOM_RECORDS_SERVICE_COMPONENTS = LOMDefaultRecordsComponents + [
        LOMToGlobalSearchComponent
    ]
    MARC21_RECORDS_SERVICE_COMPONENTS = Marc21DefaultRecordsComponents + [
        Marc21ToGlobalSearchComponent
    ]

If there is a chance that one of them is not installed, this can be handled
with ``try-except``:

.. code-block:: python

    try:
        from invenio_records_marc21.services.components import (
            DefaultRecordsComponents as Marc21DefaultRecordsComponents,
        )
    except ImportError:
        Marc21DefaultRecordsComponents = None

    if Marc21DefaultRecordsComponents is not None:
        MARC21_RECORDS_SERVICE_COMPONENTS = Marc21DefaultRecordsComponents + [
            Marc21ToGlobalSearchComponent
        ]
    else:
        MARC21_RECORDS_SERVICE_COMPONENTS = [Marc21ToGlobalSearchComponent]


Search template
---------------

.. code-block:: python

    SEARCH_UI_SEARCH_TEMPLATE = "invenio_records_dublin_core/search/search.html"

    from invenio_search_ui.views import blueprint
    from flask import render_template

    @blueprint.route("/records/search")
    def records_search():
        """Search page ui."""
        return render_template("invenio_app_rdm/records/search.html")


Schema
------

As mentioned for components, if all packages are installed, add:

.. code-block:: python

    GLOBAL_SEARCH_ORIGINAL_SCHEMAS = {
        "lom": {
            "schema": "lom",
            "name_l10n": _("OER"),
        },
        "rdm": {
            "schema": "rdm",
            "name_l10n": _("Research Result"),
        },
        "marc21": {
            "schema": "marc21",
            "name_l10n": _("Publication"),
        },
    }

If one or more is missing, simply remove the entry for the respective package.


OpenAIRE Indexing
-----------------

ListRecords & GetRecord features
================================


An InvenioRDM repository can be harvested via the Open Archives Initiative Protocol for Metadata Harvesting (OAI-PMH). OAI-PMH is a widely used protocol for harvesting metadata and most popular repository software provide support for this protocol.

Because Global search needs to support multiple data models, the default `OAISERVER_` features had to be overridden with custom function and classes that are based mostly on `global-search` index. This works also because global-search keeps track only of open-access records.

Currently supported custom OAI Features:
  - ListRecords and GetRecord for

    - metadataPrefix = oai_dc -> records from all 3 data models are serialized
    - metadataPrefix = lom -> only OER records are serialized
    - metadataPrefix = marc21 -> only Publication records are serialized

Access these by searching for the endpoint `/oai2d` and adding params like `?verb=ListRecords`. Examples:

 - `https://yourinvenio.com/oai2d?verb=ListRecords&metadataPrefix=marc21`
 - `https://yourinvenio.com/oai2d?verb=GetRecord&identifier=oai:yourinvenio.com:46t12-eng12&metadataPrefix=marc21`


Sets
====
  TODO


Further documentation is available on
https://invenio-global-search.readthedocs.io/

..
    Copyright (C) 2023-2026 Graz University of Technology.

    invenio-global-search is free software; you can redistribute it and/or
    modify it under the terms of the MIT License; see LICENSE file for more
    details.

Changes
=======

Version v0.4.2 (released 2026-05-18)

- fix: code block for changes.rst

Version v0.4.1 (released 2026-05-18)

- fix(docs): include word containing '_' in code block

Version v0.4.0 (released 2026-05-18)

- chore(docs): move to uv
- fix(docs): keep only README.rst
- chore(oai): add OAI docs
- feat(oai): move not implemented sets fetcher to GS
- tests: py 3.14
- tests: add ruff check
- fix: type errors
- feat(oai): add necessary functions for `OAISERVER_` overrides

Version v0.3.0 (release 2025-05-15)

- refactor: heavy refactoring
- tests: just python 3.12
- chore: multiple small changes
- docs: update README
- dependencies: handle libraries just if installed


Version v0.2.5 (release 2025-01-24)

- setup: only because of dev deps
- setup: remove restrictions on dependencies
- setup: update ruff/mypy configuration
- refactor: remove None defaults


Version v0.2.4 (release 2024-06-13)

- fix: catch validation error
  this ensures that rebuilding the database does not exit on the first
  error
- setup: support only python3.12



Version v0.2.3 (release 2024-02-12)

- fix: update changed lom api


Version v0.2.2 (release 2024-01-12)

- fix: permission problem


Version v0.2.1 (release 2024-01-07)

- fix: rebuild all databases


Version v0.2.0 (release 2023-11-23)

- global: rename components


Version v0.1.0 (release 2023-11-10)



