Sort order in /files and /attributes

Started by ben, December 29, 2021, 11:35:42 AM

Previous topic - Next topic

ben

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

#1
Use the sortprofile or sortby parameter to control the sort order.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ben

Quote from: Mario on December 29, 2021, 12:27:01 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

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ben

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

All parameters available for endpoints are documented in the IMWS Documentation App (available via the App Manager), e.g. for the /files endpoint:

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ben

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

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.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ben

ok thanks, that answers my initial question.