Debug incomplete movie-search results in a Django API
Company: Amazon
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Online Assessment
A Django movie database has incorrect search results. The reported investigation found a problem in the `api/search` handler and missing conditions in a query built with Django `Q` objects.
Explain how you would trace the search request, identify the handler and filtering defects, and verify a correction. The original code, schema, omitted fields, and expected search policy are unavailable, so do not claim a particular field or Boolean operator was the reported fix.
```hint Compare stages
Follow one search from the incoming URL to parsed parameters, the selected handler, the queryset, and the serialized response. Identify where its expected matches disappear or extra matches appear.
```
### Clarifying Questions
- Which movie fields should be searchable, and should matching any field or all fields qualify a result?
- Which concrete query produces an incorrect result, and which movie IDs should it return?
- How is `api/search` routed, and which handler runs for the failing request?
- Are matching rules case-insensitive, and are there separate filters, permissions, or pagination rules?
### What a Strong Answer Covers
- Reproduction with expected and observed result sets
- URL routing, handler selection, and search-parameter parsing
- Complete and correctly grouped `Q` predicates under an agreed search policy
- Regression tests spanning the database query and HTTP endpoint
### Follow-up Questions
- How would related-table joins create repeated movies in the results?
- How would you tell whether pagination or queryset filtering caused a missing movie?
- Which changes would you make if substring search became too slow for the dataset?
Overview: Investigate incorrect search results in a Django movie API, tracing the request handler and Q-object filtering. Define expected matches, verify missing predicates and Boolean grouping, and test the corrected endpoint.
Read the full Amazon Software Engineer interview experience this question came from