Skip to content

Semtexcz/invenio-oarepo-mapping-includes

Repository files navigation

OARepo Invenio data model

DC Terms data model for oarepo.

Quickstart

Add this package to your dependencies. Create a directory structure containing mappings that will be used in includes:

<project_package>
    +- included_mappings
        +- v6
            +- multilingual-v1.0.0.json

The content of multilingual-v1.0.0.json is:

{
  "MultilingualString": {
    "type": "nested",
    "properties": {
      "name": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 100
          }
        }
      },
      "lang": {
        "type": "keyword",
        "ignore_above": 3
      }
    }
  }
}

Register the included_mappings directory in entry points:

entry_points={
    'invenio_oarepo_mapping_includes': [
        '<project_package>=<project_package>.included_mappings'
    ]
},

and do not forget to run pip install.

In ES mapping you can now include types contained in multilingual-v1.0.0.json:

{
  "mappings": {
    "_doc": {
      "properties": {
        "title": {
          "type": "multilingual-v1.0.0.json#/MultilingualString"
        }
      }
    }
  }
}

The type contains the file name of the json file followed by # and json pointer to the definition.

If you want to include properties from multiple types in your properties, you can use the allOf directive:

{
  "mappings": {
    "_doc": {
      "allOf": [
         { "type": "invenio-v1.0.0.json#/InvenioRecord" },
         { "type": "dcterms-v1.0.0.json#/DCObject" }
      ],
      "properties": {
        "prop": {
          "type": "keyword"
        },
      }
    }
  }
}

Doing so will include all properties from all referenced types in your mappings properties.

When invenio index init is run, the mapping is preprocessed, "type" is dereferenced and the definition is replaced with the content found in the referenced type.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages