@@ -8,11 +8,11 @@ This application provides a REST API for managing movie data from MongoDB's samp
88
99- Spring Data MongoDB for simplified data access
1010- CRUD operations (Create, Read, Update, Delete)
11- - Text search functionality
11+ - MongoDB Atlas Search with multi-field search and compound operators
1212- Filtering, sorting, and pagination
1313- Comprehensive error handling
1414- API documentation with Swagger/OpenAPI
15- - MongoTemplate for complex queries
15+ - MongoTemplate for complex queries and aggregation pipelines
1616
1717## Prerequisites
1818
@@ -104,6 +104,7 @@ Once the application is running, you can access:
104104
105105### Movies (✅ Implemented)
106106
107+ #### CRUD Operations
107108- ` GET /api/movies ` - Get all movies (with filtering, sorting, pagination)
108109- ` GET /api/movies/{id} ` - Get a single movie by ID
109110- ` POST /api/movies ` - Create a new movie
@@ -114,6 +115,48 @@ Once the application is running, you can access:
114115- ` DELETE /api/movies ` - Delete multiple movies
115116- ` DELETE /api/movies/{id}/find-and-delete ` - Find and delete a movie
116117
118+ #### Aggregations
119+ - ` GET /api/movies/aggregations/comments ` - Get movies with most comments
120+ - ` GET /api/movies/aggregations/years ` - Aggregate movies by year with statistics
121+ - ` GET /api/movies/aggregations/directors ` - Aggregate directors with most movies
122+
123+ #### Atlas Search
124+ - ` GET /api/movies/search ` - Search movies using MongoDB Atlas Search
125+
126+ ** Query Parameters:**
127+ - ` plot ` (optional) - Search in plot field using phrase matching
128+ - ` fullplot ` (optional) - Search in fullplot field using phrase matching
129+ - ` directors ` (optional) - Search in directors field with fuzzy matching
130+ - ` writers ` (optional) - Search in writers field with fuzzy matching
131+ - ` cast ` (optional) - Search in cast field with fuzzy matching
132+ - ` searchOperator ` (optional) - Compound operator: ` must ` (default), ` should ` , ` mustNot ` , ` filter `
133+ - ` limit ` (optional) - Maximum results to return (default: 20, max: 100)
134+ - ` skip ` (optional) - Number of results to skip for pagination (default: 0)
135+
136+ ** Examples:**
137+ ``` bash
138+ # Search by plot
139+ GET /api/movies/search? plot=space+adventure
140+
141+ # Search by multiple fields with AND logic
142+ GET /api/movies/search? directors=Coppola& cast=Pacino& searchOperator=must
143+
144+ # Search by multiple fields with OR logic
145+ GET /api/movies/search? plot=crime& directors=Scorsese& searchOperator=should
146+
147+ # Search with pagination
148+ GET /api/movies/search? cast=Tom+Hanks& limit=10& skip=20
149+ ```
150+
151+ ** Note:** At least one search field must be provided. The ` searchOperator ` determines how multiple search criteria are combined:
152+ - ` must ` - All criteria must match (AND logic)
153+ - ` should ` - At least one criterion should match (OR logic)
154+ - ` mustNot ` - Criteria must not match (NOT logic)
155+ - ` filter ` - Criteria must match but don't affect scoring
156+
157+ #### Vector Search
158+ - ` GET /api/movies/find-similar-movies ` - Find similar movies using vector search on plot embeddings
159+
117160## Development
118161
119162### Running Tests
@@ -139,11 +182,19 @@ java -jar target/sample-mflix-spring-1.0.0.jar
139182
140183- ** Movies CRUD API** - Full create, read, update, delete operations
141184- ** Spring Data MongoDB** - Repository pattern with MongoTemplate for complex queries
142- - ** Text Search** - Full-text search on movie titles, plots, and genres
185+ - ** MongoDB Atlas Search** - Multi-field search with compound operators (must, should, mustNot, filter)
186+ - Phrase matching on plot and fullplot fields
187+ - Fuzzy text matching on directors, writers, and cast fields
188+ - Support for complex search queries with multiple criteria
189+ - ** MongoDB Aggregations** - Statistical aggregations by year, directors, and comments
190+ - ** Vector Search** - Find similar movies using plot embeddings (requires Atlas Vector Search)
143191- ** Filtering & Pagination** - Query parameters for filtering, sorting, and pagination
144192- ** Custom Exception Handling** - Global exception handler with proper HTTP status codes
145193- ** Type-Safe DTOs** - Specific response types instead of generic Maps
146- - ** Unit Tests** - 35 tests covering service and controller layers
194+ - ** Comprehensive Testing** - 60 tests covering service, controller, and integration layers
195+ - 29 controller unit tests
196+ - 27 service unit tests
197+ - 4 Atlas Search integration tests (requires Atlas cluster)
147198- ** OpenAPI Documentation** - Swagger UI available at ` /swagger-ui.html `
148199- ** Database Verification** - Startup checks for database connectivity and indexes
149200
@@ -165,8 +216,15 @@ This application is designed as an educational sample to demonstrate:
1652162 . Best practices for Spring Boot REST API development
1662173 . Proper separation of concerns (Controller → Service → Repository)
1672184 . MongoDB CRUD operations and query patterns
168- 5 . Error handling and validation in Spring Boot
169- 6 . Using MongoTemplate for complex queries alongside Spring Data repositories
219+ 5 . ** MongoDB Atlas Search** - Multi-field text search with compound operators
220+ - Phrase matching for exact phrase searches
221+ - Fuzzy text matching for typo-tolerant searches
222+ - Compound operators (must, should, mustNot, filter) for complex queries
223+ 6 . ** MongoDB Aggregation Pipelines** - Statistical aggregations and data transformations
224+ 7 . ** Vector Search** - Semantic similarity search using embeddings
225+ 8 . Error handling and validation in Spring Boot
226+ 9 . Using MongoTemplate for complex queries alongside Spring Data repositories
227+ 10 . Comprehensive testing strategies (unit tests, integration tests)
170228
171229## Troubleshooting
172230
0 commit comments