// for testing func main() { flag.Parse() log.SetFlags(log.Ltime | log.Lshortfile) api.Domain = *eshost response, _ := core.Index(true, "twitter", "tweet", "1", NewTweet("kimchy", "Search is cool")) indices.Flush() log.Printf("Index OK: %v", response.Ok) searchresponse, err := core.SearchRequest(true, "twitter", "tweet", "{\"query\" : {\"term\" : { \"user\" : \"kimchy\" }}}", "", 0) if err != nil { log.Println("error during search:" + err.Error()) log.Fatal(err) } // try marshalling to tweet type var t Tweet json.Unmarshal(searchresponse.Hits.Hits[0].Source, t) log.Printf("Search Found: %s", t) response, _ = core.Get(true, "twitter", "tweet", "1") log.Printf("Get: %v", response.Exists) exists, _ := core.Exists(true, "twitter", "tweet", "1") log.Printf("Exists: %v", exists) indices.Flush() countResponse, _ := core.Count(true, "twitter", "tweet") log.Printf("Count: %v", countResponse.Count) response, _ = core.Delete(true, "twitter", "tweet", "1", -1, "") log.Printf("Delete OK: %v", response.Ok) response, _ = core.Get(true, "twitter", "tweet", "1") log.Printf("Get: %v", response.Exists) healthResponse, _ := cluster.Health(true) log.Printf("Health: %v", healthResponse.Status) cluster.UpdateSettings("transient", "discovery.zen.minimum_master_nodes", 2) }
func (ec *elasticConnection) Delete(key datastore.Key) error { //func Delete(pretty bool, index string, _type string, id string, version int, routing string) (api.BaseResponse, error) { resp, err := core.Delete(false, ec.index, key.Kind(), key.ID(), 0, "") indices.Refresh(ec.index) glog.V(4).Infof("Delete response: %v", resp) if err != nil { return err } return nil }