Import Filters

  • Capella Operational
      +
      Delta Sync

      About Import Filters

      Import Filters identify the subset of documents eligible to be replicated by App services based on user-defined requirements. This subset is applied to all future mutations.

      Couchbase recommends using Import Filters. Without a filter (the default), the App Service imports all documents that are inserted or mutated within the associated linked collection of a scope in a given bucket.

      Basics

      You can enable Import Filters per App Endpoint. You can manage Import Filters at a collection level per App Endpoint. You can apply Import Filters to any Linked Collection.

      To access Import Filters:

      1. Select your desired App Endpoint.

      2. Navigate to the Settings tab within App Endpoint settings.

      3. Select the 'Import Filter' configuration option.

      4. Clink on an available linked collection from the Linked Collections table.

      5. Click the Enable Import Filter checkbox.

      6. Add your Import Filter function.

      7. Click the Save button to confirm your choice and apply the filter.

      8. You should see the Import Filter Status of the relevant linked collection change to enabled within the Linked Collections table.

      You can switch to another linked collection within the same App Endpoint to quickly and conveniently apply an existing Import Filter to a different collection.

      You must save and enable any changes to your Import Filter function before switching linked collections, or your changes will be lost.

      Working with Import Filters

      To add an Import Filter, first enable it, then enter or import a simple Javascript function into the code editor.

      The function accepts a "Document", which is a JavaScript object representing the value stored in the cluster. You should return a Boolean (true or false) to determine whether to import a document.

      For example, if you have stored the document:

      {
          "id": "0001",
          "type": "mobile",
          "value": "example"
      }

      The following Import Filter would select this record based on doc type and makes it available for the endpoint:

      function (doc) {
          return doc.type == 'mobile'; // returns `true` or `false`
      }
      The Javascript function is executed with Otto and has no access to any Capella data or features other than the doc argument.

      Once the document has been imported and processed by the App Endpoint, changing the Import Filter will not remove it, even if the updated import filters would prevent newer mutations or iterations of the document from getting imported. The Import Filter is designed for a coarse-grained filter only. Look instead to the Access Control & Data Validation function support for fine-grained read/write access control.