Last active
August 29, 2015 14:01
-
-
Save up1/62f3b65b7266ca75fb78 to your computer and use it in GitHub Desktop.
ElasticSearch with Go
This file contains 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
package main | |
import "github.com/mattbaird/elastigo/api" | |
import "github.com/mattbaird/elastigo/core" | |
func main() { | |
type Address struct { | |
ProvinceName string `json:"province_name"` | |
} | |
api.Domain = "localhost" | |
core.Index("data", "address", "1", nil, Address{"ประเทศไทย"}) | |
core.Index("data", "address", "2", nil, Address{"เพลงไทย"}) | |
} |
This file contains 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
package main | |
import "github.com/mattbaird/elastigo/api" | |
import "github.com/mattbaird/elastigo/core" | |
import "fmt" | |
func main() { | |
type Address struct { | |
ProvinceName string `json:"province_name"` | |
} | |
api.Domain = "localhost" | |
searchJson := `{"query":{"match":{"province_name":"ไทย"}}}` | |
out, _ := core.SearchRequest("data", "address", nil, searchJson) | |
for i:= 0; i<len(out.Hits.Hits); i++ { | |
fmt.Printf("%s\n", out.Hits.Hits[i].Source) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment