Skip to content

Instantly share code, notes, and snippets.

View olivere's full-sized avatar

Oliver Eilhard olivere

  • Alt F4
  • Munich, Germany
View GitHub Profile
@olivere
olivere / json_diff.go
Created October 29, 2024 06:45
JSON diff
package main
import (
"encoding/json"
"flag"
"fmt"
"os"
)
// structureInfo holds information about JSON structure
@olivere
olivere / normalize_json.go
Created October 29, 2024 06:44
Normalize JSON
package main
import (
"encoding/json"
"fmt"
"io"
"os"
"sort"
)
@olivere
olivere / go.mod
Created February 12, 2020 14:01
Connect to ES6
module example.com/es6
go 1.13
require (
github.com/mailru/easyjson v0.7.0 // indirect
github.com/olivere/elastic v6.2.27+incompatible
github.com/pkg/errors v0.9.1 // indirect
)
@olivere
olivere / mapping.go
Created December 11, 2019 15:50
Example mapping
// Copyright 2012-present Oliver Eilhard. All rights reserved.
// Use of this source code is governed by a MIT-license.
// See http://olivere.mit-license.org/license.txt for details.
// Connect creates an index with a mapping with different data types.
//
// Example
//
// mapping -url=http://127.0.0.1:9200 -index=twitter
//
@olivere
olivere / issue-907-2.go
Last active September 17, 2018 15:16
Issue 907 (2)
// Copyright 2012-present Oliver Eilhard. All rights reserved.
// Use of this source code is governed by a MIT-license.
// See http://olivere.mit-license.org/license.txt for details.
// Illustrates sorting aggs and hits.
//
// Example
//
// go run main.go -url=http://127.0.0.1:9200 -index=issue-907 -sniff=false -d
//
// Copyright 2012-present Oliver Eilhard. All rights reserved.
// Use of this source code is governed by a MIT-license.
// See http://olivere.mit-license.org/license.txt for details.
// Example code for #907.
//
// ./issue-907 -url=http://127.0.0.1:9200 -sniff=false -d
//
package main
@olivere
olivere / issue-892.go
Created September 6, 2018 08:00
Sample code
// Copyright 2012-present Oliver Eilhard. All rights reserved.
// Use of this source code is governed by a MIT-license.
// See http://olivere.mit-license.org/license.txt for details.
// Connect simply connects to Elasticsearch.
//
// Example
//
//
// connect -url=http://127.0.0.1:9200 -sniff=false
@olivere
olivere / main.go
Created May 17, 2018 13:22
Issue #774: Create and delete index
package main
import (
"context"
"log"
"github.com/olivere/elastic"
)
const (
@olivere
olivere / main.go
Created May 17, 2018 13:07
Query DSL Example #1
package main
import (
"context"
"encoding/json"
"fmt"
_ "log"
"strings"
"time"
package main
import (
"encoding/json"
"fmt"
"reflect"
)
type Article struct {
Title string `json:"title"`