|
20 | 20 | import com.mongodb.annotations.Sealed;
|
21 | 21 | import com.mongodb.client.model.Aggregates;
|
22 | 22 | import com.mongodb.client.model.geojson.Point;
|
| 23 | + |
| 24 | +import java.util.UUID; |
| 25 | + |
| 26 | +import org.bson.BsonBinary; |
| 27 | +import org.bson.BsonNull; |
23 | 28 | import org.bson.BsonDocument;
|
24 | 29 | import org.bson.BsonType;
|
25 | 30 | import org.bson.Document;
|
|
29 | 34 | import java.time.Instant;
|
30 | 35 | import java.util.Iterator;
|
31 | 36 |
|
| 37 | +import org.bson.types.ObjectId; |
| 38 | + |
32 | 39 | import static com.mongodb.assertions.Assertions.isTrueArgument;
|
33 | 40 | import static com.mongodb.internal.Iterables.concat;
|
34 | 41 | import static com.mongodb.internal.client.model.Util.combineToBsonValue;
|
@@ -293,6 +300,96 @@ static GeoNearSearchOperator near(final Point origin, final Number pivot, final
|
293 | 300 | .append("pivot", notNull("pivot", pivot)));
|
294 | 301 | }
|
295 | 302 |
|
| 303 | + /** |
| 304 | + * Returns a {@link SearchOperator} that searches for documents where a field matches the specified value. |
| 305 | + * |
| 306 | + * @param path The indexed field to be searched. |
| 307 | + * @param value The boolean value to query for. |
| 308 | + * @return The requested {@link SearchOperator}. |
| 309 | + * @mongodb.atlas.manual atlas-search/equals/ equals operator |
| 310 | + */ |
| 311 | + static EqualsSearchOperator equals(final FieldSearchPath path, final boolean value) { |
| 312 | + return new SearchConstructibleBsonElement("equals", new Document("path", notNull("path", path).toValue()) |
| 313 | + .append("value", value)); |
| 314 | + } |
| 315 | + |
| 316 | + /** |
| 317 | + * Returns a {@link SearchOperator} that searches for documents where a field matches the specified value. |
| 318 | + * |
| 319 | + * @param path The indexed field to be searched. |
| 320 | + * @param value The object id value to query for. |
| 321 | + * @return The requested {@link SearchOperator}. |
| 322 | + * @mongodb.atlas.manual atlas-search/equals/ equals operator |
| 323 | + */ |
| 324 | + static EqualsSearchOperator equals(final FieldSearchPath path, final ObjectId value) { |
| 325 | + return new SearchConstructibleBsonElement("equals", new Document("path", notNull("path", path).toValue()) |
| 326 | + .append("value", notNull("value", value))); |
| 327 | + } |
| 328 | + |
| 329 | + /** |
| 330 | + * Returns a {@link SearchOperator} that searches for documents where a field matches the specified value. |
| 331 | + * |
| 332 | + * @param path The indexed field to be searched. |
| 333 | + * @param value The number value to query for. |
| 334 | + * @return The requested {@link SearchOperator}. |
| 335 | + * @mongodb.atlas.manual atlas-search/equals/ equals operator |
| 336 | + */ |
| 337 | + static EqualsSearchOperator equals(final FieldSearchPath path, final Number value) { |
| 338 | + return new SearchConstructibleBsonElement("equals", new Document("path", notNull("path", path).toValue()) |
| 339 | + .append("value", notNull("value", value))); |
| 340 | + } |
| 341 | + |
| 342 | + /** |
| 343 | + * Returns a {@link SearchOperator} that searches for documents where a field matches the specified value. |
| 344 | + * |
| 345 | + * @param path The indexed field to be searched. |
| 346 | + * @param value The instant date value to query for. |
| 347 | + * @return The requested {@link SearchOperator}. |
| 348 | + * @mongodb.atlas.manual atlas-search/equals/ equals operator |
| 349 | + */ |
| 350 | + static EqualsSearchOperator equals(final FieldSearchPath path, final Instant value) { |
| 351 | + return new SearchConstructibleBsonElement("equals", new Document("path", notNull("path", path).toValue()) |
| 352 | + .append("value", notNull("value", value))); |
| 353 | + } |
| 354 | + |
| 355 | + /** |
| 356 | + * Returns a {@link SearchOperator} that searches for documents where a field matches the specified value. |
| 357 | + * |
| 358 | + * @param path The indexed field to be searched. |
| 359 | + * @param value The string value to query for. |
| 360 | + * @return The requested {@link SearchOperator}. |
| 361 | + * @mongodb.atlas.manual atlas-search/equals/ equals operator |
| 362 | + */ |
| 363 | + static EqualsSearchOperator equals(final FieldSearchPath path, final String value) { |
| 364 | + return new SearchConstructibleBsonElement("equals", new Document("path", notNull("path", path).toValue()) |
| 365 | + .append("value", notNull("value", value))); |
| 366 | + } |
| 367 | + |
| 368 | + /** |
| 369 | + * Returns a {@link SearchOperator} that searches for documents where a field matches the specified value. |
| 370 | + * |
| 371 | + * @param path The indexed field to be searched. |
| 372 | + * @param value The uuid value to query for. |
| 373 | + * @return The requested {@link SearchOperator}. |
| 374 | + * @mongodb.atlas.manual atlas-search/equals/ equals operator |
| 375 | + */ |
| 376 | + static EqualsSearchOperator equals(final FieldSearchPath path, final UUID value) { |
| 377 | + return new SearchConstructibleBsonElement("equals", new Document("path", notNull("path", path).toValue()) |
| 378 | + .append("value", notNull("value", new BsonBinary(value)))); |
| 379 | + } |
| 380 | + |
| 381 | + /** |
| 382 | + * Returns a {@link SearchOperator} that searches for documents where a field matches null. |
| 383 | + * |
| 384 | + * @param path The indexed field to be searched. |
| 385 | + * @return The requested {@link SearchOperator}. |
| 386 | + * @mongodb.atlas.manual atlas-search/equals/ equals operator |
| 387 | + */ |
| 388 | + static EqualsSearchOperator equalsNull(final FieldSearchPath path) { |
| 389 | + return new SearchConstructibleBsonElement("equals", new Document("path", notNull("path", path).toValue()) |
| 390 | + .append("value", BsonNull.VALUE)); |
| 391 | + } |
| 392 | + |
296 | 393 | /**
|
297 | 394 | * Returns a {@link SearchOperator} that returns documents similar to input document.
|
298 | 395 | *
|
|
0 commit comments