icatproject / icat.server

The ICAT server offering both SOAP and "RESTlike" interfaces to a metadata catalog.
Other
1 stars 5 forks source link

Speed up filterReadAccess for free text searches #277

Open patrick-austin opened 2 years ago

patrick-austin commented 2 years ago

Current behaviour

Currently, when performing a free text search using Lucene, we get results in batches of 1000, then iterate over these one by one: https://github.com/icatproject/icat.server/blob/f86b255fc7ab43cdcb55876b57966c22ff39b08a/src/main/java/org/icatproject/core/manager/EntityBeanManager.java#L784-L808

Performing authorisation first checks for root access, public tables, and failing these, gets and evaluates rules relevant to that single entity's ID: https://github.com/icatproject/icat.server/blob/f86b255fc7ab43cdcb55876b57966c22ff39b08a/src/main/java/org/icatproject/core/entity/Rule.java#L39 https://github.com/icatproject/icat.server/blob/f86b255fc7ab43cdcb55876b57966c22ff39b08a/src/main/java/org/icatproject/core/entity/Rule.java#L165-L166

Desired behaviour

There is an existing method which instead takes authorises based on several entities at once: https://github.com/icatproject/icat.server/blob/f86b255fc7ab43cdcb55876b57966c22ff39b08a/src/main/java/org/icatproject/core/manager/GateKeeper.java#L167-L246 https://github.com/icatproject/icat.server/blob/f86b255fc7ab43cdcb55876b57966c22ff39b08a/src/main/java/org/icatproject/core/entity/Rule.java#L40 https://github.com/icatproject/icat.server/blob/f86b255fc7ab43cdcb55876b57966c22ff39b08a/src/main/java/org/icatproject/core/entity/Rule.java#L167-L168

We should use this for the free text search, as we already get results in batches, and reducing the number of queries to the DB for rules should speed up the free text search component without affecting the results returned.