Skip to content

Latest commit

 

History

History
 
 

use-case-shopping

Vespa sample applications - e-commerce

A sample application showcasing a simple e-commerce site built with Vespa. Please refer to Vespa use cases for more information.

Included scripts to convert data from Julian McAuley's Amazon product data set (http://jmcauley.ucsd.edu/data/amazon/links.html) to a Vespa data feed. This repository contains a small sample of this data from the sports and outdoor category, but you can download other data from the site above and use the scripts to convert.

How to run

Check-out, compile and run:

$ git clone https://github.com/vespa-engine/sample-apps.git
$ export VESPA_SAMPLE_APPS=`pwd`/sample-apps
$ cd $VESPA_SAMPLE_APPS/use-case-shopping && mvn clean package
$ docker run --detach --name vespa --hostname vespa-container --privileged \
  --volume $VESPA_SAMPLE_APPS:/vespa-sample-apps --publish 8080:8080 vespaengine/vespa

Wait for the configserver to start:

$ docker exec vespa bash -c 'curl -s --head http://localhost:19071/ApplicationStatus'

Deploy the application:

$ docker exec vespa bash -c '/opt/vespa/bin/vespa-deploy prepare /vespa-sample-apps/use-case-shopping/target/application.zip && \
  /opt/vespa/bin/vespa-deploy activate'

Wait for the application to start:

$ curl -s --head http://localhost:8080/ApplicationStatus

Create data feed:

First, create data feed for products:

$ cat meta_sports_20k_sample.json | ./convert_meta.py > feed_items.json

Next, data feed for reviews:

$ cat reviews_sports_24k_sample.json | ./convert_reviews.py > feed_reviews.json

Feed data:

Feed products:

$ docker exec vespa bash -c 'java -jar /opt/vespa/lib/jars/vespa-http-client-jar-with-dependencies.jar \
    --file /vespa-sample-apps/use-case-shopping/feed_items.json --host localhost --port 8080'

Feed reviews:

$ docker exec vespa bash -c 'java -jar /opt/vespa/lib/jars/vespa-http-client-jar-with-dependencies.jar \
    --file /vespa-sample-apps/use-case-shopping/feed_reviews.json --host localhost --port 8080'

Test the application:

$ curl -s http://localhost:8080/search/?query=default:golf

Browse the site:

http://localhost:8080/site

Shutdown and remove the container:

$ docker rm -f vespa