eCommerce Search

eCommerce Search is one of the faceted search interfaces in SearchBlox v12. It is used to display eCommerce product data that has been indexed from a CSV file using a CSV collection.

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

Prerequisite

Please create a CSV collection and then index the CSV file that contains the eCommerce data.

Sample eCommerce data

The eCommerce plugin is set up to work specifically with the CSV file provided in the download link below.
You can download the CSV file here:
https://searchblox-downloads.s3.amazonaws.com/women.csv

Configuring fields in CSV collection for Search

You need to configure the .../webapps/ROOT/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
https://localhost:8443/ecommerce/index.html
and make some searches to view the results as shown here:

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
facetsAdd the fields you want to use as filters for eCommerce search.
collectionChoose which collection numbers to use. Use commas if adding more than one
SortBtnsAdd the “Sort By” options for sorting products.
facetFiltersOrderSet the display order of all facet filters.
sortDirChoose sort direction: ascending or descending.
pageSizeSet how many results show on each page.
showAutoSuggestTurn AutoSuggest feature on or off.
defaultCnamePick the default collection to search first.
adsDisplayTurn featured results (ads) on or off.
featuredResultsCountChoose how many featured results to show.
predictSearchTurn predicted search on or off.
predictResultSizeSet options for predicted search results.
customDateDisplayTextChange the label text for custom date filters.
customDateEnableTurn the custom date filter on or off.
relatedQueryEnable or disable related queries (default: 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": ""
dataToBeDisplayedFor CSV or database collections, choose which fields to show in the results table. If "displayAll": true, all fields are shown.
tuneImproves search result relevancy. Turn it on by setting "enable": "true".
defaultTypeSets the default search operator. "AND" means all terms must match; if not set, it uses "OR" by default.
pluginDomainThe SearchBlox domain where the plugin should get the search results from.
  • If you want to use a custom field as a facet, you must add that field in mapping.json.
    For CSV, database, MongoDB, and AWS collections, the field values must be added in their respective files: csv.json, jdbc.json, mongodb.json, and amazonS3.json located in ../webapps/ROOT/WEB-INF/.
  • If you want to add a number or date field as a facet, you must update it in mapping.json for web and file collections. For CSV, database, MongoDB, and AWS collections, the values must be added in csv.json, jdbc.json, mongodb.json, and amazonS3.json** located in ../webapps/ROOT/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 below shows the front end of the e-commerce template designed for all mobile platforms. The filter and sort buttons are available at the bottom.

  • All products have the "Add to Cart" option given below them.

  • You can click on the Filter button to view the various filter options to refine your search results.

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