icssc / anteater-api

API that provides easy access to public data from UC Irvine. Developed for Anteaters, by Anteaters.
https://anteaterapi.com/reference
GNU Affero General Public License v3.0
3 stars 0 forks source link

feat(search): implement resultType flag #21

Closed ecxyzzy closed 3 weeks ago

ecxyzzy commented 3 weeks ago

Description

Add the resultType flag that dictates what types of results are returned by the search endpoint. Can be course or instructor. Behavior is the same as the endpoint currently if not provided.

How Has This Been Tested?

Tested locally with queries using the new flag.

Types of changes

Checklist:

ecxyzzy commented 3 weeks ago

Good catch, thanks! I think this is by design for the TO_TSQUERY function, but is definitely not desirable for our uses. Will look into this and put up an additional commit.

ecxyzzy commented 3 weeks ago

Should be fixed now!

For posterity, the non-government query was probably exploding because we passed the nodes into another TO_TSQUERY call, which expanded it unnecessarily. When I was testing in psql, WEBSEARCH_TO_TSQUERY would not output a negated node unless the hyphen was the first character in a "word" (separated by spaces).

Looks like escaping the hyphen, except for where it begins a word, helped in this case. Also, queries containing only stop words will now just return an empty array rather than erroring.