Skip to content

Instantly share code, notes, and snippets.

View thigm85's full-sized avatar

Thiago G. Martins thigm85

View GitHub Profile
from vespa.package import FieldSet
app_package.schema.add_field_set(
FieldSet(name="default", fields=["title", "abstract"])
)
from vespa.package import VespaDocker
vespa_docker = VespaDocker(
port=8080,
container_memory="8G",
disk_folder="/Users/tmartins/news" # change for your desired absolute folder
)
app = vespa_docker.deploy(
application_package=app_package,
)
for article in data:
res = app.feed_data_point(
data_id=article["news_id"],
fields=article,
schema="news"
)
res = app.query(body={"yql" : "select * from sources * where default contains 'music';"})
res.hits[0]
res = app.query(body = {"yql" : "select title, abstract from sources * where title contains 'music' AND default contains 'festival';"})
res.hits[0]
res = app.query(body = {"yql" : "select title from sources * where sddocname contains 'news';"})
res.hits[0]
res = app.query(body={"yql" : "select title, date from sources * where date contains '20191110';"})
res.hits[0]
res = app.query(body={"yql" : "select title, abstract, date from sources * where default contains 'weather' AND date contains '20191110';"})
res.hits[0]
res = app.query({"yql" : "select date from sources * where date <= 20191110 AND date >= 20191108;"})
res.hits[0]
res = app.query(body={"yql" : "select title, date from sources * where default contains 'music';"})
res.hits[:2]