Author Topic: /categories/refresh question  (Read 386 times)

ben

  • Hero Member
  • ***
  • Posts: 550
/categories/refresh question
« 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.
Code: [Select]
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

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 31554
Re: /categories/refresh question
« Reply #1 on: February 10, 2022, 08:49:21 AM »
'piview_data|dates|t-00' should work.
What does IMWS respond to your request?

ben

  • Hero Member
  • ***
  • Posts: 550
Re: /categories/refresh question
« Reply #2 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

ben

  • Hero Member
  • ***
  • Posts: 550
Re: /categories/refresh question
« Reply #3 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.


Code: [Select]
'path':"piview_data|datesReaction: no update
Return:  {"result":"ok"}
Q1: This doesn't update the children. Is this expected?


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


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


Code: [Select]
'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

thrinn

  • Super Hero
  • ****
  • Posts: 1111
Re: /categories/refresh question
« Reply #4 on: February 11, 2022, 07:52:06 AM »
Code: [Select]
'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:
Code: [Select]
TEST|whatever|t-because at least "t-" is part of the path.
Thorsten
Win 10 / 64, IMatch 2018, IMA

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 31554
Re: /categories/refresh question
« Reply #5 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 \\ => \\|

ben

  • Hero Member
  • ***
  • Posts: 550
Re: /categories/refresh question
« Reply #6 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?
Code: [Select]
  'regexp':"path,piview_data\\|dates\\|t--"
  'path':"piview_data|dates|t--"



Ben

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 31554
Re: /categories/refresh question
« Reply #7 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.

ben

  • Hero Member
  • ***
  • Posts: 550
Re: /categories/refresh question
« Reply #8 on: February 11, 2022, 09:13:23 PM »
Thanks for clarification.
Now, i understand and can find a working solution for me.

Thanks
Ben