UTDNebula / nebula-api

The central API for Nebula Labs. Makes UTD data easily available through endpoints for both internal and public usage.
MIT License
26 stars 33 forks source link

Search only by specific query parameters #168

Closed AdamMcAdamson closed 9 months ago

AdamMcAdamson commented 1 year ago

To increase the efficiency of our queries, we should only match against indexed fields. If we allow searches by invalid fields (that we cannot create indexes against) it opens us up to reading every document for each empty search. So, we should only allow search by given query parameters.

In general, the documentation outlines what parameters we should be able to query by. For now, keep the query parameter names the same, we can change them down the line.

We should remove the parameters for which indexing is unrealistic/inefficient (i.e. a course's description). (Generally these are never in use) We'll need to update the documentation on the website accordingly.

TrishT201 commented 1 year ago

Hey I would like to work on this

jpahm commented 1 year ago

I'm assuming this is open for anyone to do at this point, unless @TrishT201 is still working on this in some capacity.

TortCode commented 1 year ago

I can take this up

jpahm commented 1 year ago

Sounds good, all yours. Let me know if you need any further clarification.

ahshabbir commented 1 year ago

This is something I was thinking we could solve with Filter objects. For example:

type CourseFilter struct {
  SubjectPrefix string
  CourseNumber int
...
}

This way we can type check the parameters. To solve the issue of parsing the queries, we can use the gorilla/schema library. We can then just decode this into a mongodb document and send that as part of the mongodb query. Any thoughts on this?

jpahm commented 1 year ago

I think this is a good idea. Thoughts on this @TortCode?

TortCode commented 1 year ago

I was thinking of implementing something like this manually by annotating certain fields of the models with a "canquery" tag and then making my own encoder/decoder, but I dont want to sloppily reinvent existing functionality. The solution with filters and gorilla/schema looks promising.

TortCode commented 1 year ago

do you an idea on how to handle queries of nested fields (like in professor endpoint) since we need to use dot notation for them

jpahm commented 1 year ago

do you an idea on how to handle queries of nested fields (like in professor endpoint) since we need to use dot notation for them

I wouldn't worry about supporting nested fields -- we probably shouldn't be letting people query by those since we won't be indexing such things. Unless I'm misunderstanding?

TortCode commented 1 year ago

I have the code written. I have not tested it out yet.

jpahm commented 12 months ago

I have the code written. I have not tested it out yet.

Sounds good, thanks!

jpahm commented 10 months ago

@TortCode What's the status on this?

TortCode commented 10 months ago

I need to test this out still

jpahm commented 10 months ago

I need to test this out still

No worries, just keep me updated with any progress or questions👍