Multiple values for sort key in API specs

Hi all!

My name is Carolina, I’m a developer at InSTEDD and I’m working on an implementation of FRED API in Resource Map.

We found an issue with the specs of sorting criteria.
Let’s say I want to sort by beds ‘asc’ and then by nurses ‘asc’. According to the current specification, I should send this query:
/facilities.json?sortAsc=beds&sortAsc=nurses

Then the ‘sortAsc’ query key would be duplicated.

The way that’s interpreted by default varies depending on your choice of language and/or framework. For example, .NET would yield [‘beds’,‘nurses’], PHP would yield only ‘nurses’ and Java will yield only ‘beds’. In particular, Resource Map uses Ruby on Rails, which will yield only the last value, in this case ‘nurses’. You can take a look at a discussion on the topic at: http://stackoverflow.com/questions/1746507/authoritative-position-of-duplicate-http-get-query-keys.

This will cause the query to order the results by nurses and not by beds, wich is not the spected behavior.

In order to avoid this issue we suggest to change the specification so the query is performed in the following way
/facilities.json?sort=beds:asc,nurses:asc,numServices:desc

This would be interpreted as a plain string regardless of languages and frameworks. We think this is better because in general it’s much easier to parse a string than to modify the default URI parsing behavior of the underlying framework.

Does this sound good to you?

Best regards,

···


Carolina Hadad

Manas Technology Solutions

[ar.phone] 4796.0232

[us.phone] 312.612.1050

[email] chadad@manas.com.ar

[web] man.as/caro

Thanks Carolina!
I think the language/framework we happen to use is less relevant than the issue with the spec -

would you mind posting the issue here and suggesting the change?

https://github.com/facilityregistry/fred-api/issues?state=open

Cheers-

~ ej

···

On Jan 25, 2013, at 7:15 AM, Carolina Hadad chadad@manas.com.ar wrote:

Hi all!

My name is Carolina, I’m a developer at InSTEDD and I’m working on an implementation of FRED API in Resource Map.

We found an issue with the specs of sorting criteria.
Let’s say I want to sort by beds ‘asc’ and then by nurses ‘asc’. According to the current specification, I should send this query:
/facilities.json?sortAsc=beds&sortAsc=nurses

Then the ‘sortAsc’ query key would be duplicated.

The way that’s interpreted by default varies depending on your choice of language and/or framework. For example, .NET would yield [‘beds’,‘nurses’], PHP would yield only ‘nurses’ and Java will yield only ‘beds’. In particular, Resource Map uses Ruby on Rails, which will yield only the last value, in this case ‘nurses’. You can take a look at a discussion on the topic at: http://stackoverflow.com/questions/1746507/authoritative-position-of-duplicate-http-get-query-keys.

This will cause the query to order the results by nurses and not by beds, wich is not the spected behavior.

In order to avoid this issue we suggest to change the specification so the query is performed in the following way
/facilities.json?sort=beds:asc,nurses:asc,numServices:desc

This would be interpreted as a plain string regardless of languages and frameworks. We think this is better because in general it’s much easier to parse a string than to modify the default URI parsing behavior of the underlying framework.

Does this sound good to you?

Best regards,


Carolina Hadad

Manas Technology Solutions

[ar.phone] 4796.0232

[us.phone] 312.612.1050

[email] chadad@manas.com.ar

[web] man.as/caro

Right now sorts are currently limited to one parameter. Improved docs will reflect this. We are very open to suggestions on how to get around this limitation.

···

On Jan 25, 2013 8:45 PM, “Carolina Hadad” chadad@manas.com.ar wrote:

Hi all!

My name is Carolina, I’m a developer at InSTEDD and I’m working on an implementation of FRED API in Resource Map.

We found an issue with the specs of sorting criteria.
Let’s say I want to sort by beds ‘asc’ and then by nurses ‘asc’. According to the current specification, I should send this query:
/facilities.json?sortAsc=beds&sortAsc=nurses

Then the ‘sortAsc’ query key would be duplicated.

The way that’s interpreted by default varies depending on your choice of language and/or framework. For example, .NET would yield [‘beds’,‘nurses’], PHP would yield only ‘nurses’ and Java will yield only ‘beds’. In particular, Resource Map uses Ruby on Rails, which will yield only the last value, in this case ‘nurses’. You can take a look at a discussion on the topic at: http://stackoverflow.com/questions/1746507/authoritative-position-of-duplicate-http-get-query-keys.

This will cause the query to order the results by nurses and not by beds, wich is not the spected behavior.

In order to avoid this issue we suggest to change the specification so the query is performed in the following way
/facilities.json?sort=beds:asc,nurses:asc,numServices:desc

This would be interpreted as a plain string regardless of languages and frameworks. We think this is better because in general it’s much easier to parse a string than to modify the default URI parsing behavior of the underlying framework.

Does this sound good to you?

Best regards,


Carolina Hadad

Manas Technology Solutions

[ar.phone] 4796.0232

[us.phone] 312.612.1050

[email] chadad@manas.com.ar

[web] man.as/caro

I just posted the issue and suggestion.

Thanks for the clarification on the definition that sorting can be performed on a single field, we had not noticed that discussion.

I also posted our suggestions on sorting by multiple fields.

Cheers!

···

2013/1/25 Matt Berg mlberg@gmail.com

Right now sorts are currently limited to one parameter. Improved docs will reflect this. We are very open to suggestions on how to get around this limitation.

On Jan 25, 2013 8:45 PM, “Carolina Hadad” chadad@manas.com.ar wrote:

Hi all!

My name is Carolina, I’m a developer at InSTEDD and I’m working on an implementation of FRED API in Resource Map.

We found an issue with the specs of sorting criteria.
Let’s say I want to sort by beds ‘asc’ and then by nurses ‘asc’. According to the current specification, I should send this query:
/facilities.json?sortAsc=beds&sortAsc=nurses

Then the ‘sortAsc’ query key would be duplicated.

The way that’s interpreted by default varies depending on your choice of language and/or framework. For example, .NET would yield [‘beds’,‘nurses’], PHP would yield only ‘nurses’ and Java will yield only ‘beds’. In particular, Resource Map uses Ruby on Rails, which will yield only the last value, in this case ‘nurses’. You can take a look at a discussion on the topic at: http://stackoverflow.com/questions/1746507/authoritative-position-of-duplicate-http-get-query-keys.

This will cause the query to order the results by nurses and not by beds, wich is not the spected behavior.

In order to avoid this issue we suggest to change the specification so the query is performed in the following way
/facilities.json?sort=beds:asc,nurses:asc,numServices:desc

This would be interpreted as a plain string regardless of languages and frameworks. We think this is better because in general it’s much easier to parse a string than to modify the default URI parsing behavior of the underlying framework.

Does this sound good to you?

Best regards,


Carolina Hadad

Manas Technology Solutions

[ar.phone] 4796.0232

[us.phone] 312.612.1050

[email] chadad@manas.com.ar

[web] man.as/caro


Carolina Hadad

Manas Technology Solutions

[ar.phone] 4796.0232

[us.phone] 312.612.1050

[email] chadad@manas.com.ar

[web] man.as/caro