search

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxResultsCount = 1000
)

Variables

View Source
var (
	ErrNotFound        = errors.Base("not found")
	ErrInvalidArgument = errors.Base("invalid argument")
)

Functions

func DocumentSearchAmountFilterGet

func DocumentSearchAmountFilterGet(
	ctx context.Context, getSearchService func() (*elastic.SearchService, int64), id, prop identifier.Identifier, unit string,
) (interface{}, map[string]interface{}, errors.E)

func DocumentSearchFiltersGet

func DocumentSearchFiltersGet(
	ctx context.Context, getSearchService func() (*elastic.SearchService, int64), id identifier.Identifier,
) (interface{}, map[string]interface{}, errors.E)

func DocumentSearchIndexFilterGet

func DocumentSearchIndexFilterGet(
	ctx context.Context, getSearchService func() (*elastic.SearchService, int64), id identifier.Identifier,
) (interface{}, map[string]interface{}, errors.E)

func DocumentSearchRelFilterGet

func DocumentSearchRelFilterGet(
	ctx context.Context, getSearchService func() (*elastic.SearchService, int64), id, prop identifier.Identifier,
) (interface{}, map[string]interface{}, errors.E)

func DocumentSearchSizeFilterGet

func DocumentSearchSizeFilterGet(
	ctx context.Context, getSearchService func() (*elastic.SearchService, int64), id identifier.Identifier,
) (interface{}, map[string]interface{}, errors.E)

func DocumentSearchStringFilterGet

func DocumentSearchStringFilterGet(
	ctx context.Context, getSearchService func() (*elastic.SearchService, int64), id, prop identifier.Identifier,
) (interface{}, map[string]interface{}, errors.E)

func DocumentSearchTimeFilterGet

func DocumentSearchTimeFilterGet(
	ctx context.Context, getSearchService func() (*elastic.SearchService, int64), id, prop identifier.Identifier,
) (interface{}, map[string]interface{}, errors.E)

func EnsureIndex

func EnsureIndex(ctx context.Context, httpClient *http.Client, logger zerolog.Logger, url, index string, sizeField bool) (*elastic.Client, errors.E)

EnsureIndex creates an instance of the ElasticSearch client and makes sure the index for PeerDB documents exists. If not, it creates it. It does not update configuration of an existing index if it is different from what current implementation of EnsureIndex would otherwise create.

func GetClient

func GetClient(httpClient *http.Client, logger zerolog.Logger, url string) (*elastic.Client, errors.E)

Types

type State

type State struct {
	ID       identifier.Identifier  `json:"s"`
	Text     string                 `json:"q"`
	Filters  *filters               `json:"-"`
	ParentID *identifier.Identifier `json:"-"`
	RootID   identifier.Identifier  `json:"-"`
}

State represents current search state. Search states form a tree with a link to the previous (parent) state.

func CreateState

func CreateState(s string, textQuery, filtersJSON *string) *State

CreateState creates a new search state given optional existing state and new queries.

func GetOrCreateState

func GetOrCreateState(s string, textQuery, filtersJSON *string) (*State, bool)

GetOrCreateState resolves an existing search state if possible. If not, it creates a new search state.

func GetState

func GetState(s string, textQuery *string) *State

GetState resolves an existing search state if possible.

func (*State) Query

func (q *State) Query() elastic.Query

TODO: Determine which operator should be the default? TODO: Make sure right analyzers are used for all fields. TODO: Limit allowed syntax for simple queries (disable fuzzy matching).

func (*State) Values

func (q *State) Values() url.Values

Values returns search state as query string values.

func (*State) ValuesWithAt

func (q *State) ValuesWithAt(at string) url.Values

ValuesWithAt returns search state as query string values, with additional "at" parameter.

Jump to

Keyboard shortcuts

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