Skip to content

Commit

Permalink
Add elsticsearch instance, elastic client.
Browse files Browse the repository at this point in the history
Signed-off-by: Daksh Chauhan <dak-x@outlook.com>
  • Loading branch information
dak-x committed Jul 29, 2021
1 parent eebe7f4 commit 6976234
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
20 changes: 19 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ services:
context: .
container_name: sokemotor
hostname: sokemotor

depends_on:
- elastic

networks:
- soke-elastic
ports:
Expand All @@ -17,7 +21,21 @@ services:
- ./:/app
- $GOPATH:/go/

elastic:
image: elasticsearch:7.13.4

environment:
- discovery.type=single-node

container_name: elastic
hostname: elastic
volumes:
- elastic-data:/usr/share/elasticsearch/data
networks:
- soke-elastic
networks:
soke-elastic:
driver: bridge


volumes:
elastic-data:
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ module sokemotor
go 1.16

require github.com/gin-gonic/gin v1.7.2

require github.com/elastic/go-elasticsearch/v7 v7.13.1
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/elastic/go-elasticsearch/v7 v7.13.1 h1:PaM3V69wPlnwR+ne50rSKKn0RNDYnnOFQcuGEI0ce80=
github.com/elastic/go-elasticsearch/v7 v7.13.1/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.7.2 h1:Tg03T9yM2xa8j6I3Z3oqLaQRSmKvxPd6g/2HJ6zICFA=
Expand Down
16 changes: 12 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
package main

import (
"net/http"
"log"

"github.com/elastic/go-elasticsearch/v7"
"github.com/gin-gonic/gin"
)

func main() {

_, err := elasticsearch.NewDefaultClient()
if err != nil {
log.Fatal("Elastic Instance Not Running Exiting...")
}

app := gin.Default()
app.GET("/", searchHandler)
app.GET("/search/:query", searchHandler)
app.POST("/document", documentHandler)

app.POST("/indexHtml", processHtml)
app.Run("0.0.0.0:8080")
}

func searchHandler(c *gin.Context) {
c.String(http.StatusAccepted, "You Pinged")
}

func documentHandler(c *gin.Context) {

}

func processHtml(c *gin.Context) {

}

0 comments on commit 6976234

Please sign in to comment.