CDRH / api

Codenamed "Apium": An API to access all public Center for Digital Research in the Humanities resources
https://cdrhdev1.unl.edu/api_frontend
MIT License
3 stars 1 forks source link

filter returning fields? #42

Closed jduss4 closed 7 years ago

jduss4 commented 7 years ago

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html

I think it would be useful to be able to get only a list of ids + titles, etc, back, the way that you can limit the returning fields in Solr. I imagine it would look something like this?

fields[]=id&fields[]=title

techgique commented 7 years ago

Yes, please 😄 This is handy for script cURLs where we just want one field's value or a short list of fields.

I wonder if we could even handle the includes/excludes part by preceding a field name or wildcard pattern with !. For their example, we'd write as: ?fields[]=obj1.*&fields[]=obj2.*&fields[]=!*.description

jduss4 commented 7 years ago

yeah, that seems quite possible, especially with the elasticsearch syntax to help out. @karindalziel do you know off the top of your head if that's possible with solr as a backend?

jduss4 commented 7 years ago

For the sake of shorter URLs, should this actually be comma-delineated or separated by | ?

?fields=title|author.name|date*|!date_d

Something like that? Rather than ?field[]=title&field[]=author.name&field[]=date*&field[]=!date_d

jduss4 commented 7 years ago

Changing it to fl for field or field list to make it shorter, regardless. Same name that solr uses for it (elasticsearch uses "source" )

jduss4 commented 7 years ago

In solr you may not exclude returning fields, but have to whitelist all you want if you list any. Do we want to offer blacklisting functionality knowing that if we switch the backend it would not be backwards compatible?

@karindalziel @techgique ?

jduss4 commented 7 years ago

Addressed this here: https://github.com/CDRH/api/commit/e522f329173810fa32e3e8f323a33cebabbdeb0a