[JAVA-4931] Add additional SearchOperator helper methods for the rest of the Atlas Search operators Created: 11/Apr/23  Updated: 17/Oct/23

Status: Backlog
Project: Java Driver
Component/s: Builders
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor - P4
Reporter: Erik Hatcher Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: search
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Quarter: FY24Q4
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

There are several Atlas Search query operators that are not implemented with first class support in the Java driver. For example, the `phrase` operator. Ideally it could work like this:

            Bson search_stage = search(
                    SearchOperator.compound()
                            .filter(Arrays.asList(SearchOperator.text(fieldPath("genres"), "Drama")))
                            .must(Arrays.asList(SearchOperator.phrase(fieldPath("cast"), "keanu reeves")))
            );

Whereas right now, one must know the JSON structure of the operator syntax and use the `.of()` escape hatch like this:

            Bson search_stage = search(
                    SearchOperator.compound()
                            .filter(Arrays.asList(SearchOperator.text(fieldPath("genres"), "Drama")))
                            .must(Arrays.asList(SearchOperator.of(new Document("phrase", new Document("query", "keanu reeves").append("path", fieldPath("cast"))))))
            );

https://www.mongodb.com/docs/atlas/atlas-search/operators-and-collectors/


Generated at Thu Feb 08 09:03:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.