SearchCollector.facet() does not allow null operator

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Java Drivers
    • Needed
    • Hide

      1. What would you like to communicate to the user about this feature?

      New builder API for facet without operator
      2. Would you like the user to see examples of the syntax and/or executable code and its output? - If we have existing docs that show java example with `facet` then let's add one more example

      SearchCollector.facet(
              asList(
                      stringFacet(
                              "stringFacetName",
                              fieldPath("stringFieldName")),
                      numberFacet(
                              "numberFacetName",
                              fieldPath("numberFieldName"),
                              asList(10, 20, 30)))) 

      3. Which versions of the driver/connector does this apply to?

      5.8+

      Show
      1. What would you like to communicate to the user about this feature? New builder API for facet without operator 2. Would you like the user to see examples of the syntax and/or executable code and its output? - If we have existing docs that show java example with `facet` then let's add one more example SearchCollector.facet( asList( stringFacet( "stringFacetName" , fieldPath( "stringFieldName" )), numberFacet( "numberFacetName" , fieldPath( "numberFieldName" ), asList(10, 20, 30)))) 3. Which versions of the driver/connector does this apply to? 5.8+
    • None
    • None
    • None
    • None
    • None
    • None

      MonogDB Search's "facet" collector allows for a null/non-existent operator in order to facet across the entire collection. Unfortunately `SearchCollector.facet()` does not allow for a null operator:
      https://github.com/mongodb/mongo-java-driver/blob/main/driver-core/src/main/com/mongodb/client/model/search/SearchCollector.java#L51

      This causes one to resort to drop out of the driver conveniences and do something like this:

      Arrays.asList(new Document("$searchMeta",
          new Document("index", "movies_index")
                  .append("facet",
          new Document("facets",
          new Document("year",
          new Document("type", "string")
                              .append("path", "year")
                              .append("numBuckets", 100L))))))
      

            Assignee:
            Almas Abdrazak
            Reporter:
            Erik Hatcher
            Slav Babanin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: