Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-4931

Add additional SearchOperator helper methods for the rest of the Atlas Search operators

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.4.0
    • Affects Version/s: None
    • Component/s: Builders
    • Needed
    • Hide

      Additional helper methods should be documented.

      Note that only those listed as subtasks are implemented (for example, geonear is not yet implemented).

      Show
      Additional helper methods should be documented. Note that only those listed as subtasks are implemented (for example, geonear is not yet implemented).

      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/

            Assignee:
            maxim.katcharov@mongodb.com Maxim Katcharov
            Reporter:
            erik.hatcher@mongodb.com Erik Hatcher
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: