offer

package
v0.0.0-...-6232422 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	ID                 string    `json:"id"`
	Source             string    `json:"source"`
	Title              string    `json:"title"`
	URL                string    `json:"url"`
	DiscountPercentage *int      `json:"discount_percentage"`
	Price              *float64  `json:"price"`
	Timestamp          time.Time `json:"@timestamp"`
}

Document wraps an offer item.

type Offer

type Offer struct {
	Title string
	URL   string
	Price *float64
}

Offer struct.

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository allows to index and search documents.

func NewRepository

func NewRepository(es *elasticsearch.Client, idx string) (*Repository, error)

NewRepository constructor.

func (*Repository) Create

func (s *Repository) Create(item *Document) error

Create indexes a new document into store.

func (*Repository) CreateIndex

func (s *Repository) CreateIndex(mapping string) error

CreateIndex creates a new index with mapping.

func (*Repository) Exists

func (s *Repository) Exists(item *Document) (bool, error)

Exists returns true when a document with id already exists in the store.

type StoreConfig

type StoreConfig struct {
	Client    *elasticsearch.Client
	IndexName string
}

StoreConfig configures the store.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL