When save person attribute type, only update search index if "searchable" property is saved

Description

When saving a Person Attribute Type, the PersonAttributeType search index is updated (because the searchable property of that attribute may have changed):

https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/api/impl/PersonServiceImpl.java#L187

For databases with large numbers of persons/patients, rebuilding the search could take 20-30 minutes (or more).

So, we should explicitly test if the searchable property has changed, and only update the index if this is the case.

(Ideally, the index update could be asynchronous as well, but we can handle that in a separate ticket)

Activity

Show:

Mark Goodrich June 2, 2021 at 1:40 PM

Thanks for cleaning up the fix versions and closing !

Mark Goodrich May 28, 2021 at 7:04 PM

PR against 2.3.x here: https://github.com/openmrs/openmrs-core/pull/3792

(will "up-port" to 2.4.x/master if approved)

Mike Seaton May 28, 2021 at 3:57 PM

Great catch !!   I agree with the proposal to only update the search index if a term is updated that would warrant it.

Mark Goodrich May 28, 2021 at 3:46 PM

fyi  (we ran into this while moving PAT loading to Iniz, because on first run it was attempting to re-save all the person attribute types and re-indexing each time)

Fixed

Details

Assignee

Reporter

Complexity

Low

Priority

Created May 28, 2021 at 3:42 PM
Updated June 2, 2021 at 1:40 PM
Resolved June 2, 2021 at 2:26 AM