This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from vespa.package import FieldSet | |
| app_package.schema.add_field_set( | |
| FieldSet(name="default", fields=["title", "abstract"]) | |
| ) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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, | |
| ) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | for article in data: | |
| res = app.feed_data_point( | |
| data_id=article["news_id"], | |
| fields=article, | |
| schema="news" | |
| ) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | res = app.query(body={"yql" : "select * from sources * where default contains 'music';"}) | |
| res.hits[0] | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | res = app.query(body = {"yql" : "select title, abstract from sources * where title contains 'music' AND default contains 'festival';"}) | |
| res.hits[0] | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | res = app.query(body = {"yql" : "select title from sources * where sddocname contains 'news';"}) | |
| res.hits[0] | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | res = app.query(body={"yql" : "select title, date from sources * where date contains '20191110';"}) | |
| res.hits[0] | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | res = app.query(body={"yql" : "select title, abstract, date from sources * where default contains 'weather' AND date contains '20191110';"}) | |
| res.hits[0] | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | res = app.query({"yql" : "select date from sources * where date <= 20191110 AND date >= 20191108;"}) | |
| res.hits[0] | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | res = app.query(body={"yql" : "select title, date from sources * where default contains 'music';"}) | |
| res.hits[:2] |