O'Reilly logo

Distributed Computing with Go by V.N. Nikhil Anurag

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing /api/query

In order to test /api/query we need to maintain the preceding state of the server to make useful queries:

$ # Querying for "apple" 
 
$ curl -LX POST -d '["apple"]' localhost:9090/api/query | jq    
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current        
                                 Dload  Upload   Total   Spent    Left  Speed          
100   202  100   193  100     9    193      9  0:00:01 --:--:--  0:00:01 40400         
{                                           
  "count": 2,                               
  "data": [                                 
    {                                       
      "doc_id": "Book 1",                   
      "doc_score": 2,                       
      "token_indices": [                    
        {                                   
          "Index": 0,                       
          "LIndex": 0                       
        },                                  
        {                                   
          "Index": 0,                       
          "LIndex": 1                       
        }                                   
      ]                                     
    },                                      
    {                                       
      "doc_id": "Book 3",                   
      "doc_score": 1,                       
      "token_indices": [                    
        {                                   
          "Index": 0,                       
          "LIndex": 0                       
        }                                   
      ]                                     
    }                                       
  ]                                         
} 
 
$ # Querying for "cake" 
$ curl -LX POST -d '["cake"]' localhost:9090/api/query | jq % Total % Received % Xferd Average Speed Time Time Time Current ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required