JSONADM API and rebuild index

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
matteovg7
Posts: 14
Joined: 12 Dec 2019, 16:13

JSONADM API and rebuild index

Post by matteovg7 » 17 Mar 2020, 16:52

Hi, when a new product is associated with a category in catalog, for example, it is necessary to rebuild the index in order to view it in the frontend.
When this operation is made with JSONADM API, how is possible to rebuild the index, for example every time the new relationship is patched?
Thank you.

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: JSONADM API and rebuild index

Post by aimeos » 18 Mar 2020, 09:53

There's no way to rebuild the index using the JsonAdm API because it's a potentially long running operation that takes much longer than the request is allowed to. It's also not possible to execute the cronjob from the API.

The only possibility might be to create a job in the message queue and a corresponding job controller that rebuild the index if there's a job in the queue. But there are a few things to keep an eye on: Rebuild jobs must not be executed in parallel and what if there are a lot of jobs in the queue due to several changes? Are they all executed one by one? Is only the first executed and what if another change requires to rebuild a product whose index records already has been rebuild?

Our suggestion would be to rebuild only the index entries of the product whose reference has been added, modified or deleted like it's done for the product in the JQAdm interface:
https://github.com/aimeos/ai-admin-jqad ... #L227-L228

Can you create a PR for this change?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

matteovg7
Posts: 14
Joined: 12 Dec 2019, 16:13

Re: JSONADM API and rebuild index

Post by matteovg7 » 18 Mar 2020, 11:56

https://github.com/aimeos/ai-admin-jsonadm/pull/6

I tried in my extension and this code works when adding a product in a category, so it works also when any other relationships of the product is patched.
I don't know if there are other stuff to take care (other domains that needs to rebuild the index, etc).

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: JSONADM API and rebuild index

Post by aimeos » 18 Mar 2020, 15:47

Fixed a few things in your code and extended the tests:
https://github.com/aimeos/ai-admin-json ... #L438-L445

Now, PATCH and POST will update the index but still does not DELETE.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

matteovg7
Posts: 14
Joined: 12 Dec 2019, 16:13

Re: JSONADM API and rebuild index

Post by matteovg7 » 19 Mar 2020, 08:55

In the next days I will do a PR also for DELETE method.

Post Reply