-
Notifications
You must be signed in to change notification settings - Fork 8
Adds ability to search keys and their corresponding values #309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Conversation
Once tested and merged in master would close #270 |
Two quick things:
|
I've set to merge this onto staging to test performance before opening another PR to merge into master. kv_search should be based on master. When I do:
That's the last common ancestor, which is a PR onto master that was the last point I had interacted with before working on this branch. It's just behind master a bit. |
Regarding url paths we have a bit of a mixed bag here. To retrieve the values of the cid key on this single document it then goes If we stayed consistent it would logically follow then that /api/documents/data/ then should show all of the full key/value pair combinations across all documents visible to the user, but that isn't what we want with this, but can be added. If we want to stay consistent we can either add an endpoint for a single document /api/documents/data/keys/ that shows us only the keys present on a single document, or make it so that /document/{document_pk}/data/ works by returning only keys. That would be a backwards incompatible change. |
Thanks for the clarification!
The question for me here is the performance cost of returning all the values for all the documents, but if it's not high then I really like that as an enhancement of what currently exists—it's consistent with the other behavior. Then, it's up to me as a developer if I just want to read all the keys, or all the keys and their values. If there's a high performance cost, then I agree with your approach: placing the list of just keys under the I'm focused on performance because returning suggestions for search and autocomplete is a big user case, and we'd want responses as fast as possible. One middle ground to consider would be a "keys-only" option on the list to tune performance based on the request's needs.
I like this consistency between the API for keys between single documents and all documents.
Given my question about performance, I think my order of preference for consistency would be:
|
I will save this PR for approach 1. I will open a 2nd PR that encapsulates this different approach to see if it is performant.
There will be no endpoint specifically for keys, rather that will be extracted from /documents/data/ in post-processing |
Limited to keys/values that appear on documents viewable to the user.
Endpoints are:
/api/documents/data/keys/
/api/documents/data/keys/{key}/values/
Chose this demonstrate that we are searching across several documents' data fields. Can change this.
Example of all keys visible to this user:

Example of all values for a particular key (color) for this user:

Can restrain further by providing a project ID.

Similarly with values

I had concerns about user provided key names so I used a regular expression to validate that the input is an alphanumeric.