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

Custom Fields in Search

Adding Custom Fields in Faceted Search

SearchBlox fields such as title, keywords, language, etc., as well as custom fields such as meta fields for HTTP collections, author and subject fields for file collections can be added as facets in faceted search. All fields indexed via CSV, Database and MongoDB collections can also be added as facets in faceted search.

Steps to Add Facets

Step 1:
Stop SearchBlox.

Step 2:
For custom fields in HTTP, File collection, RSS collection and custom collections, add the fields in ../webapps/searchblox/WEB-INF/mapping.json.

For custom fields in CSV collections, add the snippet in ./webapps/searchblox/WEB-INF/csv.json.
In Database collections, add the snippet in ./webapps/searchblox/WEB-INF/jdbc.json.
And for MongoDB collections, add the snippet in ./webapps/searchblox/WEB-INF/mongodb.json.

Example:
Add the following snippet in mapping.json, csv.json, jdbc.json or mongodb.json based on the collection for each custom field. Enter the name of the custom field in the beginning
"customfieldname": {
"type": "text",
"store": true,
"fielddata": true,
"analyzer": "comma_analyzer"
},

Example:
"subject": {
"type": "text",
"store": true,
"fielddata": true,
"analyzer": "comma_analyzer"
},

Add the above snippet without making any syntax errors. Add the field after another field without missing any commas.

Step 3:
In order to add these facets, the facets need to be updated in ../webapps/searchblox/plugin/facet.js
as below:

"facets": [{
            "field": "colname",
            "display": "Collection Name",
            "size": "10"
        },
         {
            "field": "subject",
            "display": "Subject",
            "size": "10"
        },
        {
            "field": "contenttype",
            "display": "File Type",
            "size": "10"
        },
        {
            "field": "keywords",
            "display": "keywords",
            "size": "10"
        },
        {
            "field": "lastmodified",
            "display": "Last Modified",
            "dateRange": [{
                    "name": "Last 24 hours",
                    "calendar": "days",
                    "value": "1"
                },
                {
                    "name": "Past Week",
                    "calendar": "days",
                    "value": "7"
                },
                {
                    "name": "Past Month",
                    "calendar": "months",
                    "value": "1"
                },
                {
                    "name": "Past Year",
                    "calendar": "years",
                    "value": "1"
                }
            ]
        }
    ],

Step 4:
Start SearchBlox and reindex.

  • Custom fields will only be added as filter facets using the steps above.
  • Custom fields can either appear as filter facets or they can be searched. Both cannot happen simultaneously.
  • If you want custom fields to be searchable, follow the instructions in the below section.
    Please note that a field can be mapped only once in the JSON file

Making Custom Fields Searchable

By default, custom fields from HTTP, File and Custom collections cannot be searched even if they are added as facets using the steps outlined in the above section.

If you need the content from meta fields or custom fields to be searched, add the following mapping to the mapping.json file found within the /searchblox/WEB-INF folder. Restart SearchBlox and then reindex the collection.

"section":{
"type": "text",
"copy_to": "custom_all"
},

Applicable for HTTP, File, RSS and Custom Collection

Custom Fields in Search


Suggested Edits are limited on API Reference Pages

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