Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
src
README.md
adsdata.xml
pom.xml

README.md

Predicate Search

Predicate/Boolean Search and how to feed and query is described in predicate search.

To deploy this sample application see Developing applications.

Adding predicate search to an application is easy. Just add a field of type predicate to the .sd file. (Remember to set the arity parameter.)

Feed and search

  1. Feed the data that is to be searched:

    curl -X POST --data-binary @adsdata.xml <endpoint url>/document
  2. Search using yql expressions, e.g. select * from sources * where predicate(target, {"name":"Wile E. Coyote"},{});

    curl "<endpoint url>/search/?query=sddocname:ad&yql=select%20*%20from%20sources%20*%20where%20predicate(target%2C%20%7B%22name%22%3A%22Wile%20E.%20Coyote%22%7D%2C%7B%7D)%3B"

Executable example

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/boolean-search && 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/boolean-search/target/application.zip && \
  /opt/vespa/bin/vespa-deploy activate'

Wait for the application to start:

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

Feed data into application:

$ curl -s -X POST --data-binary @${VESPA_SAMPLE_APPS}/boolean-search/adsdata.xml http://localhost:8080/document

Test the application:

$ curl "http://localhost:8080/search/?query=sddocname:ad&yql=select%20*%20from%20sources%20*%20where%20predicate(target%2C%20%7B%22name%22%3A%22Wile%20E.%20Coyote%22%7D%2C%7B%7D)%3B" | python -m json.tool

Shutdown and remove the container:

$ docker rm -f vespa