Skip to content

Commit

Permalink
Change Elasticsearch image
Browse files Browse the repository at this point in the history
  • Loading branch information
tinrab committed Mar 21, 2018
1 parent 0aabbc5 commit 3b778c3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 31 deletions.
8 changes: 3 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ services:
- elasticsearch
elasticsearch:
container_name: 'elasticsearch'
image: 'elasticsearch:5.6.8'
command: elasticsearch
expose:
- '9200'
- '9300'
image: 'docker.elastic.co/elasticsearch/elasticsearch:6.2.3'
ports:
- '9200:9200'
26 changes: 13 additions & 13 deletions search-api/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions search-api/Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@
version = "1.2.0"

[[constraint]]
name = "gopkg.in/olivere/elastic.v5"
version = "5.0.66"
name = "github.com/olivere/elastic"
version = "6.1.12"

[[constraint]]
name = "github.com/teris-io/shortid"
version = "1.0.0"

[prune]
go-tests = true
Expand Down
17 changes: 6 additions & 11 deletions search-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,19 @@ import (
"time"

"github.com/gin-gonic/gin"
"github.com/olivere/elastic"
"github.com/teris-io/shortid"
elastic "gopkg.in/olivere/elastic.v5"
)

type Document struct {
ID string `json:"id"`
Title string `json:"title"`
CreatedAt time.Time `json:"created_at"`
Content string `json:"content"`
Suggest *elastic.SuggestField `json:"suggest_field"`
ID string `json:"id"`
Title string `json:"title"`
CreatedAt time.Time `json:"created_at"`
Content string `json:"content"`
}

const (
elasticIndexName = "blog"
elasticIndexName = "documents"
elasticTypeName = "document"
)

Expand All @@ -45,9 +44,6 @@ const mapping = `
"type": "text",
"store": true,
"fielddata": true
},
"suggest_field": {
"type": "completion"
}
}
}
Expand Down Expand Up @@ -167,7 +163,6 @@ func searchEndpoint(c *gin.Context) {
docs := make([]DocumentResponse, 0)
for _, hit := range result.Hits.Hits {
var doc DocumentResponse
// Leave empty document if unmarshal fails
json.Unmarshal(*hit.Source, &doc)
docs = append(docs, doc)
}
Expand Down

0 comments on commit 3b778c3

Please sign in to comment.