Example #1
0
 def __ensure(self):
     try:
         res = rest.head(self.url)
     except urllib2.HTTPError, e:
         if e.code == 404:
             rest.put(self.url, {"mappings":
                                     {"truck": {
                                         "properties": {
                                             "location": {"type": "geo_point"},
                                             "updated": {"type": "date"}
                                         }
                                     }}})
         else:
             raise e
Example #2
0
 def add(self, id, document):
     """
     Add a document to the index.
     """
     rest.put("{}/{}/{}".format(self.url, self.type, id), document)