MongoDB Collection

A MongoDB collection can be created using the following steps:

Creating MongoDB Collection

  • After logging in to the Admin Console, click Add Collection button. The Add Collection screen will be displayed.
  • Enter a unique name for your collection (for example, MongoDB).
  • Select MongoDB collection radio button.
  • Click Add to create the collection.

MongoDB Collection Settings

  • The Settings sub-tab holds collection settings for MongoDB and tunable parameters for the search.
  • MongoDB settings values must be set explicitly for MongoDB collections.
  • The mandatory settings for MongoDB collection are
    • Host Name
    • Port Number
    • MongoDB Type
    • MongDB Database Name
    • MongoDB Database Collection
  • SearchBlox also comes pre-configured with few parameters when a new MongoDB collection is created which can be modified as required.
  • The following table has the list of settings available in MongoDB collection
Host NameIP address or name of the MongoDB host (default value is localhost).
Port NumberPort number of MongoDB.
MongoDB TypeDefault value is local.
User NameUser name in MongoDB (leave the username and password fields empty if no username is available).
PasswordPassword used in MongoDB.
MongoDB Database NameDatabase name to be indexed.
MongoDB Database CollectionCollection to be indexed.
Bulk SizeThe number of documents(BSON documents) to be taken at a time for indexing.
Keyword-in-Context DisplayThe keyword-in-context returns search results with the description displayed from content areas where the search term occurs.
BoostingBoost search terms for the collection by setting a value greater than 1 (maximum value 9999).
StemmingWhen stemming is enabled, inflected words are reduced to root form. For example, "running", "runs", and "ran" are the inflected form of "run".
Spelling SuggestionsWhen enabled, a spelling index is created at the end of the indexing process.

Steps to Set Up MongoDB for Searchblox Indexing

Steps for setting replica and oplog in MongoDB:

  • Start MongoDB with the command mongod:
    mongod --replSet rs0 --oplogSize 100
  • Start MongoDB with the command mongo and run:
> show dbs
local (empty)
> use local
switched to db local
> rs.initiate()
"info2" : "no configuration explicitly specified -- making one",
"me" : "MONGOSERVER:27017",
"info" : "Config now saved locally. Should come online in about a minute.",
"ok" : 1
> show collections
  • Create collections in MongoDB with settings:
dbtype : local
        dbname : <database name>
        collection name: <collection name within local>

Indexing and Other Operations

The following operations can be performed in a MongoDB collection:

IndexStarts the indexer for the selected collection.
ClearClears the current index for the selected collection.
Scheduled ActivityFor each collection, any of the following scheduled indexer activity can be set:
Index - Set the frequency and the start date/time for indexing a collection.
Clear - Set the frequency and the start date/time for clearing a collection.
  • Indexer activity is controlled from the Index sub-tab in the collection. The current status of an indexer for a particular collection is indicated.
  • Indexing operation starts the indexer for the MongoDB collection.
  • On reindexing that is, clicking on index again after the initial index operation, all crawled documents will be reindexed. If documents have been deleted from MongoDB since the first index operation, they will be deleted from the index. New documents will also be indexed.
  • Also, indexing is controlled from the Index sub-tab for a collection or through API. The current status of a collection is always indicated on the Collection Dashboard and the Index page.
  • Index operation can also be initiated from the Collection Dashboard.
  • Scheduling can be performed only from the Index sub-tab.

Schedule Frequency

Schedule Frequency supported in SearchBlox is as follows:

  • Once
  • Every Minute
  • Hourly
  • Daily
  • Every 48 Hours
  • Every 96 Hours
  • Weekly
  • Monthly


Best Practices

  • Please cross-check the steps to set up MongoDB in our documentation with your MongoDB admin for successful indexing of collection
  • Specify the correct and relevant settings of MongoDB in the MongoDB collection settings
  • Do not schedule the same time for index and clear operations
  • If you have multiple collections, always schedule the activity to prevent more than 2-3 collections indexing at the same time.


Setup ReactJS Faceted Search UI for MongoDB data