debate-cards
debate-cards copied to clipboard
Implement graphql api with search
Not ready for public use, would need some sort of rate limiting and ways to prevent expensive queries.
Uses apollo-server for now Uses type-graphql to define resolvers and models Uses fields requested in query to create select object that is passed into prisma. This has some performance benefits and automatically makes queries on relations work.
Search uses a query_string query as the base for now. Fields being searched and their weights can be customized in query or defaults can be used Evidence can be filtered by tags using a terms_set filter. To boost cards with a lot of duplicates, a function_score query is used with a script_score function. Final score is calculated as $baseScore \cdot duplicateCount^{duplicateWeight}$ where duplicateWeight can be specified in the query and is almost always between 0 and 1. The duplicateCount is indexed from the count field on evidenceBucket entities (which at the moment is usually slightly incorrect when the count is high, will have to look into that) Results are collapsed based on the bucketId, so only the doc with the highest score from a bucket is returned Only the ids of the documents are returned from the elastic query, and then id's are used in a second prisma query so relations can work properly
TODO
- [x] Add rate limiting/prevent expensive queries
- [x] Add pagination for search and for one to many relationships
- [ ] Maybe some sort of file uploading
- [x] Add authentication
- [ ] Cite and round report search
- [x] Easier ways to query for caselist data than ids