Skip to content

Simple AngularJS 1.x online store app as a vehicle for experimenting with Elasticsearch

Notifications You must be signed in to change notification settings

taylorjg/BasketCase

Repository files navigation

Description

A little Angular 1.x app as a vehicle for grokking Elasticsearch. It supports the following functionality:

  • free text search
  • pagination
  • filtering via facets

Try it out

Try it on Heroku (it may take 10s to re-activate)

Design

The front end is an Angular 1.x app. The back end is a Node.js / Express server that uses the Elasticsearch npm package to implement a web service end point, /api/search.

Request format

{
    "filters": [{
        "name": "brand",
        "keys": ["Beko", "Hotpoint"]
    }, {
        "name": "price",
        "keys": ["250-300"],
    }],
    "currentPage": 1,
    "pageSize": 10,
    "sortBy": 0
}
{
    "searchText": "beko 7kg",
    "currentPage": 1,
    "pageSize": 10,
    "sortBy": 0
}

Response format

{
    "results": {
        "total": 7,
        "products": [{
            "Brand": "Beko",
            "FitTypeName": "Free Standing",
            "FullTitle": "Beko WMB71233S 7Kg Washing Machine with 1200 rpm - Silver",
            "Price": 250,
            "RatingValue": 4.6,
            "EnergyRating": "A+++",
            "Image": "//media.ao.com/en-GB/Productimages/Images/rvMedium/beko_wmb71233s_si_01_m_p.jpg",
            "ReviewCount": 5,
            "Code": "WMB71233S_SI",
            "Colour": "Silver"
        },
        ...
        ]
    },
    "facets": [{
        "name": "fitType",
        "displayName": "Fit Type",
        "type": "multi",
        "facetValues": [{
            "displayName": "Free Standing",
            "key": "Free Standing",
            "count": 6,
            "selected": false
        }, {
            "displayName": "Built In",
            "key": "Built In",
            "count": 1,
            "selected": false
        }]
    }, {
        "name": "brand",
        "displayName": "Brand",
        "type": "multi",
        "facetValues": [{
            "displayName": "Beko",
            "key": "Beko",
            "count": 6,
            "selected": true
        }, {
            "displayName": "Hoover",
            "key": "Hoover",
            "count": 3,
            "selected": false
        },
        ...
        ]
    }, {
        "name": "colour",
        "displayName": "Colour",
        "type": "multi",
        "facetValues": [{
            "displayName": "Black",
            "key": "Black",
            "count": 3,
            "selected": false
        }, {
            "displayName": "White",
            "key": "White",
            "count": 3,
            "selected": false
        }, {
            "displayName": "Silver",
            "key": "Silver",
            "count": 1,
            "selected": false
        }]
    }, {
        "name": "price",
        "displayName": "Price",
        "type": "single",
        "facetValues": [{
            "displayName": "£200 or less",
            "key": "undefined-200",
            "count": 2,
            "selected": false,
        }, {
            "displayName": "£200 - £250",
            "key": "200-250",
            "count": 7,
            "selected": false,
        },
        ...
        ]
    }]
}

TODO

  • sorting of results by various criteria
  • autocompletion in the search box
  • breadcrumbs
  • deep linking
  • unit tests