`Collection.updateSearchIndex` fails for vector search indexes

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Gone away
    • Priority: Unknown
    • None
    • Affects Version/s: 6.13.0, 6.16.0
    • Component/s: None
    • 2
    • Not Needed
    • None
    • Hide

      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?

      Show
      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?
    • None
    • None
    • None
    • None
    • None
    • None

      Problem:

      I am trying to use `collection.createSearchIndex()` and `collection.updateSearchIndex()` to programmatically manage a vector search index.

      Here's the shape of the index definition:

       

      const index = {
        name: "test_vector_search_index",
        type: "vectorSearch",
        definition: {
          fields: [...],
        },
      };

      When I call `collection.createSearchIndex(index)` with this definition, it creates the index with no problems.

      However, when I call `collection.updateSearchIndex(index.name, index.definition)`, it throws the following error:

      MongoServerError: "userCommand.mappings" is required
          at Connection.sendCommand (.../npm_mongodb_6.13.0-6d6f49b5/files/src/cmap/connection.ts:548:17)
          at Connection.command (.../npm_mongodb_6.13.0-6d6f49b5/files/src/cmap/connection.ts:622:22)
          at Server.command (.../npm_mongodb_6.13.0-6d6f49b5/files/src/sdam/server.ts:335:21)
          at UpdateSearchIndexOperation.execute (.../npm_mongodb_6.13.0-6d6f49b5/files/src/operations/search_indexes/update.ts:34:5)
          at tryOperation (.../npm_mongodb_6.13.0-6d6f49b5/files/src/operations/execute_operation.ts:283:14)
          at executeOperation (.../npm_mongodb_6.13.0-6d6f49b5/files/src/operations/execute_operation.ts:115:12)
          at Collection.updateSearchIndex (.../npm_mongodb_6.13.0-6d6f49b5/files/src/collection.ts:1265:12)
          [local frames]
      {
        errorLabelSet: Set(0) {},
        errorResponse: {
          ok: 0,
          errmsg: '"userCommand.mappings" is required',
          code: 8,
          codeName: 'UnknownError',
          '$clusterTime': {
            clusterTime: new Timestamp({ t: 1745871047, i: 39 }),
            signature: [Object]
          },
          operationTime: new Timestamp({ t: 1745871047, i: 39 })
        },
        ok: 0,
        code: 8,
        codeName: 'UnknownError',
        '$clusterTime': {
          clusterTime: new Timestamp({ t: 1745871047, i: 39 }),
          signature: {
            hash: Binary.createFromBase64('AAAAAAAAAAAAAAAAAAAAAAAAAAA=', 0),
            keyId: 0
          }
        },
        operationTime: new Timestamp({ t: 1745871047, i: 39 })
      } 

      However, the documentation for search indexes clearly states that `mappings` is only required for regular search indexes, not vector search indexes.

      I believe there is incorrect validation going on, either client side (in the Node.js driver) or server-side. Please correct me if I am wrong and show me the correct way to update a vector index.

       

       

      Most of the template below is not applicable.

      ======

      Use Case

      As a... developer
      I want... this bug fixed
      So that... I can update search indexes programmatically

      User Experience

      • What is the desired/expected outcome for the user once this ticket is implemented?
      • If bug: What is the number of impacted customers? How severe is the impact? Is anyone blocked or broken?

      Dependencies

      • upstream and/or downstream requirements and timelines to bear in mind

      Risks/Unknowns

      • What could go wrong while implementing this change? (e.g., performance, inadvertent behavioral changes in adjacent functionality, existing tech debt, etc)
      • Is there an opportunity for better cross-driver alignment or testing in this area?
      • Is there an opportunity to improve existing documentation on this subject?

      Acceptance Criteria

      Implementation Requirements

      • functional reqs, potential snafus to avoid, performance targets, etc

      Testing Requirements

      • unit test, spec test sync, etc

      Documentation Requirements

      • DOCSP ticket, API docs, etc

      Follow Up Requirements

      • additional tickets to file, required releases, etc
      • if node behavior differs/will differ from other drivers, confirm with dbx devs what standard to aim for and what plan, if any, exists to reconcile the diverging behavior moving forward

            Assignee:
            Bailey Pearson
            Reporter:
            Justin McBride
            None
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: