A newer version of this documentation is available.

View Latest
March 30, 2025
+ 12

Introducing import filters and how to use them to speed-up the initial import process.

Introduction

The purpose of the import filter is to identify the subset of documents eligible to be replicated by Sync Gateway. This subset is based on application requirements, and is applied to all future mutations.

Without a filter (the default), Sync Gateway imports all documents and so we recommend use of this import filter unless there is a compelling use-case against it.

Function Provision

Use the Database Configuration Admin Rest API endpoint /{db}/_config/import_filter to provision an import filter for a database using the application/javascript mime type.

If you are using legacy configuration then, you need to include it in your configuration file, see: import-filter.

Configuration

Example 1. Using an Import Filter
//
curl -X PUT "http://localhost:4985/froglist/_config/import_filter" \
-H "accept: application/json" \
-H "Content-Type: application/javascript" \
-H "Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=" \ (1)
-d "\"function(doc) {\ if (doc.type != 'mobile') {\ return false\ }\ return true\}\\\""
//
1 You will need to provide authentication in the call; unless it is disabled (not recommended in production environment).