Welcome to Voyager Help

Use the Search field below or select a Category from the list at the left

Indexing MongoDB Databases

Dependencies

Python (32-bit) must be installed on the Voyager Server machine. Ideally, the Python version should be 2.7.

DO NOT USE EARLIER VERSIONS OF PYTHON

Indexing Data

After confirming the dependencies, you need to add a new location.

To create a new location: 

  1. Go to Manage > Discovery > Locations 
  2. Go to the Add Locations section 
  3. Click Databases (Advanced)
  4. Select MongoDB in the Connections drop-down list 
  5. Edit the configuration (see examples below)

Configuration Examples

Example 1

This configuration indexes all the collections in a MongoDB database. It includes all the fields and maps only one field for all tables. The use of the asterisk (*) in this configuration means to include all fields, all tables and apply the field mapping in all tables.


{
  "name": "mongodb_sample1",
  "type": "python",
  "config": {
    "fields": {
      "include": ["*"]
    },
    "tables": [
      {
        "name": "*",
        "action": "INCLUDE"
      },
      {
        "name": "*",
        "map": {"NAME": "name"}
      }
    ],
    "mongodb": {
      "client": "mongodb://localhost:27017/",
      "database": "usa"
    }
  }
}

Example 2

Index a single collection.


{
    "name": "USA_CITIES",
    "type": "python",
    "config": {
        "fields": {
            "include": ["*"]
        },
    "tables": [
    {
        "name": "CITIES",
        "action": "INCLUDE"
    },
    {
        "name": "*",
        "map": {
            "NAME ": "name"
            }
    } ],
   “wkt”: “true”,
    "mongodb": {
      "client": "mongodb://localhost:27017/",
      "database": "usa"
     }
    }
  }
}

Example 3

This example demonstrates the following:

  1. Index two collections
  2. Map fields for each collection
  3. Perform a query on each collection

{
  "name": "MongoDB_Sample3",
  "type": "python",
  "config": {
    "fields": {"include": ["*"]},
    "tables": [
      {
        "name": "STATES",
        "action": "INCLUDE"
        "map": {"STATE_NAME": "name"},
        "query": "{‘STATE_NAME’:  'California'}"
      },
      {
        "name": "CITIES",
        "action": "INCLUDE"
        "map": {"CITY_NAME": "name"},
        "query": "{‘CITY_NAME’:  'Redlands'}"
      }
    ],
    "mongodb": {
      "client": "mongodb://localhost:27017/",
      "database": "usa"
     }
  }
}

Example 4

This example demonstrates the support for GridFS. GridFS is a convention in MongoDB for storing files or arbitrary size and convenient for storing large files and binary objects in MongoDB. In this example, the key “gridfs” is included and set to “true”. For more information about GridFS, see here.


{
  "name": "MongoDB_GridFS",
  "type": "python",
  "config": {
    "fields": {
      "include": ["*"]
    },
    "tables": [
      {
        "name": "fs.files",
        "action": "INCLUDE"
      },
      {
        "name": "null.files",
        "action": "INCLUDE"
      },
      {
        "name": "*",
        "map": {
          "uuid": "id",
          "filename": "name",
          "author": "author"
        }
      }
    ],
    "mongodb": {
      "client": "mongodb://localhost:27017/",
      "database": "largefiles",
      "gridfs": "true"
    }
  }
}

Usage Notes

  • Geographic information is included in the index for collections with geometry. For point features, the X and Y coordinate location is indexed. For other geometries, the extent coordinates (bounding box) are recorded. Geometries stored in a “loc” field or as GeoJSON are supported.
  • The Well-known text for each geometry can be optionally included in the index. This can be done by setting the “wkt” option to “true”. CAUTION: the WKT can be very large for complex polygons and lines.
Web Design and Web Development by Buildable