eCommerce Search

eCommerce Search is one of the faceted search interfaces available from SearchBlox 9.1. This eCommerce search can be used displaying eCommerce data indexed from a CSV file using a CSV collection.

To access eCommerce plugin please use the following link in your build
https://localhost:8443/searchblox/ecommerce/index.html

Prerequisite

Please create CSV collection and index the CSV file which has the eCommerce data.

1344

Sample eCommerce data

The ecommerce plugin has been configured to be used specifically for the CSV file provided in the following download link.
You can download the sample CSV file here:
http://d2bs75lu2qxj7h.cloudfront.net/plugins/ecommerce/women.csv

Configuring fields in CSV collection for Search

You have to configure .../webapps/searchblox/WEB-INF/csv.json file with the fields you want to display as shown here:

"parent_category": {
        "type": "text",
        "store": true,
        "index": true,
        "analyzer": "comma_analyzer",
        "fielddata": true,
        "boost": "1"
      },
"retail": {
        "type": "double",
        "store": true,
        "index": true
      },
"sale": {
        "type": "double",
        "store": true,
        "index": true
      },
"rating": {
        "type": "text",
        "store": true,
        "index": true,
        "analyzer": "comma_analyzer",
        "fielddata": true,
        "boost": "1"
      },
"category1": {
        "type": "text",
        "store": true,
        "index": true,
        "analyzer": "comma_analyzer",
        "fielddata": true,
        "boost": "1"
      },
"colors":{
        "type": "text",
        "store": true,
        "index": true,
        "analyzer": "comma_analyzer",
        "fielddata": true,
        "boost": "1"
},
"neck":{
        "type": "text",
        "store": true,
        "index": true,
        "analyzer": "comma_analyzer",
        "fielddata": true,
        "boost": "1"
},
"fit":{
        "type": "text",
        "store": true,
        "index": true,
        "analyzer": "comma_analyzer",
        "fielddata": true,
        "boost": "1"
},

Steps to use eCommerce Plugin

Once the collections are created and indexed you can directly access the plugin using the link
http://localhost:8080/searchblox/ecommerce/index.html
and make some searches to view the results as shown here:

1139

Fields in facets.js

The content of facet.js are as shown:

window.facets = {
  "facets":[
        {"field": "fit", "display": "Fit","size":"10"},
        {"field": "colors",  "display": "Colors","size":"10"},
        {"field": "neck","display": "Neck","size":"10"},
        {"field": "category1","display": "Category","size":"10"},
        {"field": "parent_category","display": "Parent Category","size":"10"},
        {"field": "rating","display": "Ratings","size":"10"},
        {"field": "retail","display":"Price",
          "range":[
            {"name":"0-50","from":"*","to":"50"},
            {"name":"51-100","from":"51","to":"100"},
            {"name":"101-150","from":"101","to":"150"},
            {"name":"151-200","from":"151","to":"200"},
            {"name":"201-","from":"201","to":"*"}
          ]
        }
    ],
    "collection": [],
    "sortBtns":[
        {"field":"sale","display":"Sort by Sale"},
        {"field":"rating","display":"Sort by Rating"}
    ],
    "facetFiltersOrder": [
      "category1","parent_category","fit","colors","neck","rating","retail"
    ],
    "facetFiltersType": "AND",
    "sortDir": "desc",
    "pageSize": "12",
    "showAutoSuggest": "true",
    "autoSuggestParams": {
      "col": 1,
      "field": "test",
      "type": "custom"
    },
    "defaultCname": "",
    "adsDisplay": "true",
    "featuredResultsCount": "3",
    "predictSearch": "false",
    "predictResultSize": "3",
    "customDateDisplayText":"Custom",
    "customDateEnable":"false",
    "relatedQuery": false,
    "relatedQueryFields": {
        "apikey": "931EADAA71EA0B8A5A9DBDEAE99384E5",
        "field": "content",
        "operator": "and",
        "limit": "5",
        "terms": "10",
        "type": "phrase",
        "col": ""
    },
    "ratingmaxcount":"5",
    "dataToBeDisplayed": {
        "1": {
            "title": "Title",
            "description": "Description"
        },
        "other": {
            "description": "Description"
        },
        "displayAll": true
    },
    "tune": {
        "enable": "true",
        "tune.0": "5",
        "tune.1": "3",
        "tune.2": "2",
        "tune.3": "5",
        "tune.4": "180",
        "tune.5": "10"
    },
    "defaultType": "",
    "pluginDomain": ""
};

The description of the fields in the preceding js file is provided in the following table:

FieldDescription
facetsSpecify facet fields here. Facet filters for ecommerce search are included here.
collectionUsing this field you can specify/limit the collections to be used for this plugin. You can specifiy one or more collections in this field. The collection numbers must be specified as digits, if more than one collection they have to be separated by comma.
SortBtnsSort By field has to be provided here.
facetFiltersOrderOrder of facet filters to be displayed in plugin has to be specified here
sortDirThe direction of sort whether ascending or descending has to be specified here
pageSizeUsing this parameter the number of results per page can be controlled in faceted search
showAutoSuggestAutosuggest can be enabled or disabled using this parameter
defaultCnameThis is to specify default collection in which the search has to be made in the beginning
adsDisplayFeatured results can be enabled or disabled in search results using this
featuredResultsCountThe number of featured results to be displayed in the results can be specified here
predictSearchPredicted results can be enabled using this field
predictResultSizeParameters for predicted search can be specified here
customDateDisplayTextThis is for custom date label change in facet filters
customDateEnableThis is to enable or disable custom date
relatedQueryEnable or disable related query by giving true or false value for this field. By default it would be true
relatedQueryFieldsIf you want related queries in search results then specify the API key within the field. Also you can limit it based on collection by giving specific column number.
"apikey": "BFC82BE93A351C018CB27C32E1138047",
"field": "content",
"operator": "and",
"limit": "5",
"terms": "10",
"type": "phrase",
"col": ""
dataToBeDisplayedThis is specific for collections like csv and database where results have to appear in tabular format. The fields can be specified here.
If "displayAll" is true within this field all the data would be fetched from the results
tuneTune parameter for relevancy of search results. This can be enabled by giving "enable": "true", within this field
defaultTypeif AND is specified then boolean operator AND would be used in searching multiple terms. If none is specified it would be OR search
pluginDomainThe domain of SearchBlox where the plugin has to fetch results
  • If you need to a custom 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/.
  • 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/.
    ref: Custom Fields in Search

🚧

Please Note

  • Ecommerce plugin is a sample plugin designed to work with our preceding sample file.
  • Customization would be required if the fields and their data type vary.

Mobile eCommerce Template

  • The image shown below is the front end of the template created for e-commerce websites for all mobile platforms. The filter and sort buttons are provided at the bottom.
477
  • All products have the "Add to Cart" option given below them.
461
  • You can click on the Filter button to view the various filter options to refine your search results.
629

You can click on the Sort button to choose between Sort by Rating and Sort by Price.

459