SearchBlox

SearchBlox Developer Hub

Welcome to the SearchBlox developer hub. Here you will find comprehensive guides and documentation to help you start working with SearchBlox as quickly as possible, as well as support if you get stuck. Let's jump right in!

Guides

Database Search

AngularJS Search for Database, CSV and MongoDB Collections

AngularJS-based Database Search front-end for SearchBlox can be used for a grid-based result for database, CSV and MongoDB collections.

Steps to Install and Configure an AngularJS Plugin for Database and CSV Collections

  1. Remove or rename the existing plugin folder in ../webapps/searchblox.
  2. Download the zip file from https://github.com/searchblox/database-search and expand the folder into the SearchBlox installation under ../webapps/searchblox.
  3. Access the AngularJS-based search page at http://localhost:8080/searchblox/plugin/index.html.
  4. Edit the /plugin/data/facet.json file to add/modify/remove term, number range and date range filters.
  5. Add sorting options and faceted search options on the facet.json file.
    Facet.json is the configuration file that provides options that can be configured to provide search results as required. The path for the facet.json file, after placing the plugin folder in SearchBlox, is ../webapps/searchblox/plugin/data/facet.json.

To add a new facet filter, define the field name, display name and the size of the filter values to be shown. The contents of facet.json are explained below.

"facets":[
    {"field": "contenttype", "display": "Content Type","size":"10"}, // term facet filters
    {"field": "keywords",  "display": "Keywords","size":"10"},
    {"field": "colname","display": "Collection","size":"10"},
    {"field": // number range facet filters
        "size","display":"Size",
        "slider": true, // true/false to enable/disable slider filter
        "range":[
        {"name":"&lt 100kB","from":"*","to":"102400"}, // define the from and to values to setup a range
        {"name":"100kB to 500kB","from":"102400","to":"512000"},
        {"name":"500kB to 1MB","from":"512000","to":"1048576"},
        {"name":"1MB to 10MB","from":"1048576","to":"10485760"},
        {"name":"10MB &gt","from":"10485760","to":"*"} // * can be used to define the higher or lower ranges
    ]},
    {"field": "lastmodified","display":"Modified Date", // date range facet filters
        "dateRange":[
            {"name":"Last 24 hours","calendar":"days","value":"1"}, // look back values can be specified in days, months, years within the calendar
            {"name":"Past Week","calendar":"days","value":"7"},
            {"name":"Past Month","calendar":"months","value":"1"},
            {"name":"Past Year","calendar":"years","value":"1"}
        ]}
],
 
"collection":[], // Use collection id or list of collection ids comma separated to limit the Collections to be searched from the form field
 
"collectionForAds":[], // Use collection id or list of collection ids comma separated to limit the Featured Results to be shown to just the specified collections instead of displaying the Featured Results to all collections
 
"sortBtns":[ // Sort buttons for any field can be added here to display at the top of the results.
    {"field":"alpha","display":"Alphabetic"},
    {"field":"date","display":"Date"},
    {"field":"relevance","display":"Relevance"}
],
 
"matchAny":"off", // Match any terms "off" or "on". Default is match all terms
 
"sortDir":"desc", // sorting direction asc or desc for ascending or descending order
 
"pageSize": "10", // Number of results per page
 
"showAutoSuggest": "true" // turn off autosuggest by setting this value to false
 
// grid columns
"gridColumns": [
    {
        "name": "Id",
        "width": 50,
        "field": "@no"
        "cellTemplate": "<i ng-bind=\"COL_FIELD\"></i>"
    },
    // To add new column
    {
        // Name to display on column header (required)
        "name": "Title",
 
        // exact match of field name from response  (required)
        "field": "title",
 
        // size of column (optional)
        "width": 50,
 
        // custom template for column (COL_FIELD is dynamic value) (optional)
        "cellTemplate": "<button><b ng-bind=\"COL_FIELD\"></b></button>",
    },
]

Create Visualization

You can create visualizations by clicking the Create Visualizations button at the top right-hand corner above the search results.

Configuring Database Collection Results

Sample database results in JSON:

[{
"keywords": " 1 John physics California VCU",
"description": "",
"created_at": "2015-12-02T06:43:32.528Z",
"_autocomplete": " 1 John physics California VCU",
"source": "{\"no\":1,\"fname\":\"John\",\"dept\":\"physics\",\"address\":\"California\",\"university\":\"VCU\"}",
"title": "1",
"content": " 1 John physics California VCU",
"contenttype": "db",
"uid": "1"
 
},{
"keywords": " 2 Smith Chemistry Arizona ACR",
"description": "",
"created_at": "2015-12-02T06:43:32.531Z",
"_autocomplete": " 2 Smith Chemistry Arizona ACR",
"source": "{\"no\":2,\"fname\":\"Smith\",\"dept\":\"Chemistry\",\"address\":\"Arizona\",\"university\":\"ACR\"}",
"title": "2",
"content": " 2 Smith Chemistry Arizona ACR",
"contenttype": "db",
"uid": "2"
 
},{
"keywords": " 3 Caty Biology Texas TCS",
"description": "",
"created_at": "2015-12-02T06:43:32.532Z",
"_autocomplete": " 3 Caty Biology Texas TCS",
"source": "{\"no\":3,\"fname\":\"Caty\",\"dept\":\"Biology\",\"address\":\"Texas\",\"university\":\"TCS\"}",
"title": "3",
"content": " 3 Caty Biology Texas TCS",
"contenttype": "db",
"uid": "3"
 
}
]

Changes in facet.json grid columns based on the sample data above:

"gridColumns": [
        {
            "name": "Id",
            "width": 50,
            "field": "@no"
        },
        {
            "name": "Title",
            "cellTemplate": "<button class=\"text-left btn-link\" data-ng-click=\"getExternalScopes().modal(row.entity)\"><b ng-bind=\"COL_FIELD\"></b></button>",
            "field": "title"
        },
        {
            "name": "Description",
            "field": "keywords",
            "cellTemplate": "<div ng-bind-html=\"row.entity.keywords\"></div>"
        },
        {
            "name": "Name",
            "field": "source.address",
            "cellTemplate": "<i ng-bind=\"COL_FIELD\"></i>"
        },
     {
            "name": "Address",
            "field": "source.fname",
            "cellTemplate": "<i ng-bind=\"COL_FIELD\"></i>"
        },
        {
            "name": "Last modified",
            "field": "lastmodified",
            "cellTemplate": "<i ng-bind=\"COL_FIELD\"></i>"
        }
    ]
}

Results in AngularJS faceted search:

Sample CSV Collection and MongoDB Collection Results Grid

Configuring CSV and MongoDB collections is similar to configuring database collections. The sample results of CSV and MongoDB collections are listed below.

In MongoDB there is no source attribute so the attribute name can be directly given:
mongodb facet.json

{
        "name": "no",
        "field": "x",
        "cellTemplate": "<i ng-bind=\"COL_FIELD\"></i>"
    },
 {
        "name": "ID",
        "field": "_id",
        "cellTemplate": "<i ng-bind=\"COL_FIELD\"></i>"
    },

Database Search


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.