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

Faceted Search

In faceted search (also known as out-of-the-box search), information can be accessed based upon dynamic classification. Faceted search uses a faceted classification system in which indexed information can be accessed and explored from various dimensions using filters. The facets allow you to filter data through multiple paths and different ordering, and also click on any combination of facets to get the desired results.

Features and Facets

SearchBlox can perform a customized search using this faceted search functionality. The default facets available are keywords, file type and date. You can filter the search results by selecting the required combination of facets.

How to Perform a Faceted Search

The SearchBlox faceted search can be accessed through the following URL:
localhost:8080/searchblox/plugin/index.html

Provide the search term in the search field and press enter. The search results page with the facets will appear in the left-hand menu as shown in the screenshot below:

The default facets for filters such as file type, keyword and modified date can be found in the left-hand menu. After selecting each filter, the facets will appear above the search results as buttons. By clicking the button, the facet can be removed from the search results as shown in the image below.

  • File Type lists the file types available in the search results for filtering.
  • Keywords lists the words that are the keywords of the search, other than the search term results.
  • Modified Date has five options ranging from week to year, along with customized date range.
    You can also add collection as a facet by making changes in ../plugin/data/facet.json
    • Collection lists the collections that have the search results for the given search term.
      Similarly, you can also add other meta tags as facets.

Adding a Facet in Searchblox

SearchBlox also supports Collection, Title, Category, Description, Language, Author and Subject as facets. The last two facets (author and subject) are applicable for only pdf files.
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 in facet.json. Facet filters can be string, number or date types. Except for the predefined facets such as keywords, title, description, size or date, if you need add more custom facets, you can add them in facet.json (eg: facet field: "category").

The collection to be searched can be specified using the collection attribute. Similarly, the collection for which ads are to be displayed can be specified in the collection for ads field. The other fields that can be specified via facet.json are sortbtns, sortdir, pagesize, showautosuggest and matchany

The contents of facet.json are shown below.

"facets":[
    {"field": "contenttype", "display": "Content Type","size":"10"}, // term facet filters
    {"field": "keywords",  "display": "Keywords","size":"10"},
    {"field": "cname","display": "Collection","size":"10"},
    {"field": "category","display": "Collection","size":"10"},
    {"field": "size","display":"Size", // number range facet filters
        "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
  • If you need to a meta field as facet, then the field has to be mapped in mapping.json. For CSV, database, MongoDB and AWS collections, the values need to be mapped in csv.json, jdbc.json, mongodb.json, amazonS3.json respectively here: ../webapps/searchblox/WEB-INF/.
    ref: https://developer.searchblox.com/docs/custom-fields-in-search
  • If you need to add a facet field for type number or date, the field needs to be updated in ../webapps/searchblox/WEB-INF/mapping.json for web and file collections. For CSV, database, MongoDB and AWS collections, the values need to be mapped in csv.json, jdbc.json, mongodb.json, amazonS3.json respectively here: ../webapps/searchblox/WEB-INF/.

For example, if you need to add a date field "published" as a facet field, the following addition has to be made in mapping.json. Then update the field in facet.json.

Please note that you need to restart, clear and reindex if changes are made to mapping.json.

"published":{
"type":"date",
"store":"yes",
"include_in_all":"false"
},

Sorting Search Results

In faceted search, users can sort the search results based on date, alphabetic order and relevance using the drop-down provided at the top of the search results and below search box. The ascending or descending order of sorting can also be selected via drop-down.

Other Search Settings

The other search settings that can be used in faceted search are:

  • Partial search
  • Fuzzy search
  • Exact match search
  • Match All
  • No. of results per page
  • Autocomplete
    These search features can be turned on or edited by clicking the Settings icon on the right corner of the search text box and then selecting the feature.

AutoSuggest
Autosuggest/Autocomplete is enabled by default in faceted search. This feature can be disabled from the search settings if required. The number of autosuggest values can also be limited using the "suggestions per page" option in search settings.

Passing Parameters Through Faceted Search URL

In faceted search, filter search results by passing the parameters along with the query as shown in the URL below:
http://localhost:8080/searchblox/plugin/index.html?query=news AND keywords:cnn
More than one parameter can also be passed through the URL:
http://localhost:8080/searchblox/plugin/index.html?query=news AND keywords:cnn AND content:world