Author Topic: Sort order in /files and /attributes  (Read 519 times)

ben

  • Hero Member
  • ***
  • Posts: 550
Sort order in /files and /attributes
« on: December 29, 2021, 11:35:42 AM »
Hello,

i am currently debugging a script and it basically does what it should.
I am combining the information from two endpoints v1/files and v1/attributes.
For v1/attributes i am also sending the parameter "returnempty" so that both returned lists have the same length.

I get all the information i need, but the returned array of both endpoints are not in the same order.
Is this the way it works?
For example, do the first entries of v1/files and v1/attributes not refer to the same file?

My python payloads i am using with request.get() are as follows:
payloadFiles = {'idlist':'@imatch.filewindow.active.selection', 'fields': 'id,ext,size,filename', 'auth_token':auth}
payloadAttr  = {'idlist':'@imatch.filewindow.active.selection', 'set': 'PIV', 'attributes': 'Orig_vidStart,Orig_vidEnd', 'returnempty': True , 'auth_token':auth}

Returned data is:
files[0] = {'id': 83764, ...}        from v1/attributes
files[1] = {'id': 83765, ...}

result[0] = {'id': 83765, ...}        from v1/attributes
result[1] = {'id': 83764, ...}


Thanks for any clarification
Ben

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 31554
Re: Sort order in /files and /attributes
« Reply #1 on: December 29, 2021, 12:27:01 PM »
Use the sortprofile or sortby parameter to control the sort order.
« Last Edit: December 29, 2021, 12:43:45 PM by Mario »

ben

  • Hero Member
  • ***
  • Posts: 550
Re: Sort order in /files and /attributes
« Reply #2 on: December 29, 2021, 07:18:46 PM »
Use the sortprofile or sortby parameter to control the sort order.
How do i use the sortby parameter?
I checked the following sources but only find somehow similar parameters:

  - https://www.photools.com/dev-center/doc/imatch/tutorial-recipes.html
  - IMatch WebServices™ Documentation

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 31554
Re: Sort order in /files and /attributes
« Reply #3 on: December 29, 2021, 07:52:35 PM »
These are for the /files endpoint.

ben

  • Hero Member
  • ***
  • Posts: 550
Re: Sort order in /files and /attributes
« Reply #4 on: December 30, 2021, 03:49:09 PM »
Sorry, i don't understand what you mean.
Can i use the sortby parameter for both endpoints /files and /attributes?
Where do i find its documentation?

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 31554
Re: Sort order in /files and /attributes
« Reply #5 on: December 30, 2021, 05:08:03 PM »
All parameters available for endpoints are documented in the IMWS Documentation App (available via the App Manager), e.g. for the /files endpoint:


ben

  • Hero Member
  • ***
  • Posts: 550
Re: Sort order in /files and /attributes
« Reply #6 on: January 02, 2022, 11:28:43 PM »
I read the documentation again. The sortby parameter is only listet for /files but not for /attributes.
If i run the sample commands from the documentation in the browser, then the /files endpoint considers the sortby parameter. But the /attributes doesn't.
This is all consistent.

So now i am back to my initial question.
How can i combine information from /files and /attributes? If they cannot be sorted the same way, then there is no simple way.
I could of course loop through all IDs of /files and then search for the corresponding ID in /attributes.

I can live with this workaround, i just wanted to get confirmation if thats the way it is.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 31554
Re: Sort order in /files and /attributes
« Reply #7 on: January 03, 2022, 12:02:55 AM »
You have only what the endpoints support.
Just retrieve both sets and reconcile as needed by your application. Sorting stuff in Python is easy, so this should be not much of a burden.

ben

  • Hero Member
  • ***
  • Posts: 550
Re: Sort order in /files and /attributes
« Reply #8 on: January 03, 2022, 10:13:23 AM »
ok thanks, that answers my initial question.