Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parent-Child support #64

Open
jma opened this issue Mar 23, 2017 · 2 comments
Open

Parent-Child support #64

jma opened this issue Mar 23, 2017 · 2 comments

Comments

@jma
Copy link

jma commented Mar 23, 2017

Add the possibility to specify the parent id and parent document type during indexing.

@lnielsen
Copy link
Member

lnielsen commented Dec 12, 2017

This is how it should be specified for Elasticsearch:

Now in terms of Invenio-Indexer API I see two options:

Option 1) Explicit specify parent

RecordIndexer.index(child_record, parent=parent_record.id)
RecordIndexer.index_by_id(child_record_id, parent=parent_record_id)
RecordIndexer.bulk_index([(child_id, parent_id), ...])

Option 2) Programmatically extract parent from record

The Invenio Indexer API would stay unchanged:

RecordIndexer.index(child_record)
RecordIndexer.index_by_id(child_record_id)
RecordIndexer.bulk_index([child_id, ...])

Parent should then either be stored or programmatically deteremined from some other record field:

2a) Stored in RecordMetadata

RecordMetadata:
  id = ..
  json = ..
  version_id = ...
  created = ...
  updated = ...
  parent = ForeignKey(RecordMetadata.id)

With this FK constraints can be enforced by the database.

2b) Stored in the record:

Record({'_parent': 'parent record id'})

2c) Stored or calculated from another field:

record = Record({'parent': {'$ref': 'http://..../asdsd'}})
parent_record_id = parent_for_record(record)

Personally I think I'm mostly leaning towards option 2a, since it allow to enforce the foreign key constraints.


In addition to Invenio-Indexer, parent-child support is probably needed in Records-REST/UI (specifying endpoints for sub records, parent-child aggregations etc).


Use cases

Some few uses cases for parent-child relationships include:

Record<->Annotation
Record<->Files (e.g. CERN OpenData 15k files for in a record)

@jirikuncar
Copy link
Member

IMHO the parent-child relationship would be better expressed by PID relation (see also inveniosoftware/invenio-records-rest#185).

@lnielsen lnielsen added this to the someday milestone Mar 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants