Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Entities are not correctly reindexed following document #3672

@PascalRepond

Description

@PascalRepond

Bug description:

The index of entities (remote and local) contain a field organisations, which is used to filter which entities are displayed in the public search and autocomplete, according to if they are linked to documents in a specific organisation. This means that all entities linked to a document should be reindexed every time a document is modified.

However, this is not working as expected for multiple reasons:

  1. This indexing is made as bulk and the bulk_indexing is disabled by default in the config (and in production too).
  2. The function to reindex entities is called index_contributions() and it only targets remote entities that are contributions, instead of all linked entities. See: https://github.com/rero/rero-ils/blob/staging/rero_ils/modules/documents/api.py#L375-L393
  3. There is an incorrect condition if not ref that prevents the indexing to ever be made by this function (an entity always has a field $ref).
  4. The public search and autocomplete doesn't filter entities by their field "organisations" in a viewcode like it does for documents. It shows entities that are not linked to the current organisation.

Expected behavior:

  1. Every time a document is reindexed (resource modified, holdings or file added), the linked entities should be reindexed so that they contain the correct "organisations".
  2. When in a public view for an organisations, only the entities that are linked to documents in this oprganisation should be displayed in the autocomplete and results list (same as documents)
  • Write tests that check this behaviour.
  • Enable bulk_indexing (at least in the production and test servers) so that the function can run.
  • Correct the index_contributions function so that it indexes ALL entities linked to the document (remote or local, whatever the field)
  • Make sure that in the public entities search for a specific organisations, I can only see the entities that are linked to my organisation.

Steps to Reproduce:

Problem 1 (reindex)

  1. Edit a document that belongs to an organisation by adding a contributor or subject (linked entity)
  2. See in the index for the entity you just added that field "organisations": [] is empty

Problem 2 (filter)

  1. Find an entity that is linked to a document from only one (or zero) organisation
  2. Search for this entity in the public view of another organisation
  3. See that the entity shows up in the autocomplete and in the results list, even though there are no documents linked to it in the current org

Metadata

Metadata

Assignees

Labels

bugBreaks something but is not blockingf: public uiPublic interface, as opposed to the professional interfacef: search

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions