photools.com Community

IMatch Discussion Boards => IMatch Scripting and Apps => Topic started by: ben on February 09, 2022, 09:33:57 PM

Title: /categories/refresh question
Post by: ben on February 09, 2022, 09:33:57 PM
Hello everyone,

i am trying to update a category and its children by using the endpoint /v1/categories/refresh.
Unfortunately it doesn't refresh the children.

I tried to use "path" and also "regexp" parameter to define which category to update, but it seems i am not doing it right.
My category hierarchy looks as follows.
piview_data |
      dates |
         t-00
         t-01
         ..
         t-14


piview_data and dates are regular categories. Whereas t-00, t-01, ..., t-14 are data driven categories (automatic update is off).

I want to update all children t-00, t-01, ..., t-14
How should i correctly define the path?



Thanks  a lot
Ben
Title: Re: /categories/refresh question
Post by: Mario on February 10, 2022, 08:49:21 AM
'piview_data|dates|t-00' should work.
What does IMWS respond to your request?
Title: Re: /categories/refresh question
Post by: ben on February 10, 2022, 02:47:42 PM
The response is:
{"result":"ok"}

I tried different combinations again and it seems to work.
I had some files that had problematic metadata and the write back didn't work.
Maybe this was the reason why the category was signaling still "this datadriven category needs to be refreshed".

Anyways, thanks for the help.

Ben
Title: Re: /categories/refresh question
Post by: ben on February 10, 2022, 10:43:46 PM
I did some further tests since i wasn't sure about my results i got (/v1/categories/refresh):
Would be nice if you could have a look on my questions.


'path':"piview_data|dates
Reaction: no update
Return:  {"result":"ok"}
Q1: This doesn't update the children. Is this expected?


'path':"piview_data|dates|t-"
Reaction: no update
Return: {"result":"ok"}
Q2: Shouldn't this return "NOK", since the category "t-" doesn't exist?


'path':"piview_data|dates|t-00"
Reaction: update "t-00" but not the other children
Return: {"result":"ok"}
Q3: No question, reaction as expected


'regexp':"path,piview_data|dates|t-"
Reaction: updates all children "t-xx"
Return: {"result":"ok"}
Q4: Am i using the "regxep" parameter correctly?

Thanks a lot
Ben
Title: Re: /categories/refresh question
Post by: thrinn on February 11, 2022, 07:52:06 AM
Quote from: ben on February 10, 2022, 10:43:46 PM
'regexp':"path,piview_data|dates|t-"
Reaction: updates all children "t-xx"
Return: {"result":"ok"}
Q4: Am i using the "regxep" parameter correctly?
I don't know about the endpoint, but from a RegExp perspective I guess you should escape the "|" because it is a special character. My guess is that your regexp would also update something like:
TEST|whatever|t-
because at least "t-" is part of the path.
Title: Re: /categories/refresh question
Post by: Mario on February 11, 2022, 03:49:54 PM
| has a special meaning in regular expressions and must be escaped with \
Since \ has a special meaning in JavaScript strings, it must be escaped as \\ => \\|
Title: Re: /categories/refresh question
Post by: ben on February 11, 2022, 05:54:45 PM
I am using the regexp now, and escaping as "\\|".
This works, thanks thrinn and Mario.


What is left:
In case i provide a category that doesn't exist, the result of the endpoint is still {"result":"ok"}
Wouldn't we expect "nok" for both cases?
  'regexp':"path,piview_data\\|dates\\|t--"
  'path':"piview_data|dates|t--"




Ben
Title: Re: /categories/refresh question
Post by: Mario on February 11, 2022, 06:10:36 PM
This endpoint hands over the refresh to a background processing task queue. The category is then refreshed at some later time.
It does not know if the category exists or not. So, always "ok" unless parameters are missing etc.

If this is an issue, get the category you plan to update so you know if it exists or not.
Title: Re: /categories/refresh question
Post by: ben on February 11, 2022, 09:13:23 PM
Thanks for clarification.
Now, i understand and can find a working solution for me.

Thanks
Ben