Documentation ¶
Index ¶
- Constants
- Variables
- type Action
- type Document
- type Facet
- type FacetCollection
- type FacetItem
- type FacetType
- type Filter
- type KeyValueFilter
- type Media
- type PaginationPage
- type PaginationPageSize
- type Promotion
- type QueryFilter
- type RedirectError
- type RequestQueryHook
- type Result
- type SearchMeta
- type SearchService
- type SortFilter
- type SortOption
- type Suggestion
Constants ¶
const ( // SortDirectionAscending general asc value SortDirectionAscending = "A" // SortDirectionDescending general desc value SortDirectionDescending = "D" // SortDirectionNone general not set value SortDirectionNone = "" )
const ( // SuggestionTypeProduct represents product suggestions SuggestionTypeProduct = "product" // SuggestionTypeCategory represents category suggestions SuggestionTypeCategory = "category" )
Variables ¶
var ( // ErrNotFound error ErrNotFound = errors.New("search not found") )
Functions ¶
This section is empty.
Types ¶
type Action ¶ added in v3.9.0
Action might be considered on the frontend to be taken depending on search results
type FacetCollection ¶
FacetCollection for all available facets
type FacetItem ¶
type FacetItem struct { Label string Value string Active bool Selected bool // Tree Facet Items []*FacetItem // Range Facet Min, Max float64 SelectedMin, SelectedMax float64 Count int64 }
FacetItem contains information about a facet item
type Filter ¶
type Filter interface { // Value very generic method for filters - returning typical Parameter Name and its setted values Value() (string, []string) }
Filter interface for search queries
func NewKeyValueFilters ¶
NewKeyValueFilters - Factory method that you can use to get a list of KeyValueFilter based from url.Values
type KeyValueFilter ¶
type KeyValueFilter struct {
// contains filtered or unexported fields
}
KeyValueFilter allows simple k -> []values filtering
func NewKeyValueFilter ¶
func NewKeyValueFilter(k string, v []string) *KeyValueFilter
NewKeyValueFilter factory
func (*KeyValueFilter) KeyValues ¶
func (f *KeyValueFilter) KeyValues() []string
KeyValues of the current filter
func (*KeyValueFilter) Value ¶
func (f *KeyValueFilter) Value() (string, []string)
Value of the current filter
type PaginationPage ¶
type PaginationPage struct {
// contains filtered or unexported fields
}
PaginationPage - if search supports pagination this filter tells which page to return
func NewPaginationPageFilter ¶
func NewPaginationPageFilter(page int) *PaginationPage
NewPaginationPageFilter factory
func (*PaginationPage) GetPage ¶
func (f *PaginationPage) GetPage() int
GetPage of the current filter
func (*PaginationPage) Value ¶
func (f *PaginationPage) Value() (string, []string)
Value of the current filter
type PaginationPageSize ¶
type PaginationPageSize struct {
// contains filtered or unexported fields
}
PaginationPageSize - if search supports setting the amount (limit) per page
func NewPaginationPageSizeFilter ¶
func NewPaginationPageSizeFilter(page int) *PaginationPageSize
NewPaginationPageSizeFilter factory
func (*PaginationPageSize) GetPageSize ¶
func (f *PaginationPageSize) GetPageSize() int
GetPageSize of the current filter
func (*PaginationPageSize) Value ¶
func (f *PaginationPageSize) Value() (string, []string)
Value of the current filter
type Promotion ¶ added in v3.4.0
type Promotion struct { Title string Content string URL string Media []Media AdditionalAttributes map[string]interface{} }
Promotion result during search
type QueryFilter ¶
type QueryFilter struct {
// contains filtered or unexported fields
}
QueryFilter - represents a query string, normally given by a user in the search result
func (*QueryFilter) Value ¶
func (f *QueryFilter) Value() (string, []string)
Value of the current filter
type RedirectError ¶
type RedirectError struct {
To string
}
RedirectError suggests to redirect
func (*RedirectError) Error ¶
func (re *RedirectError) Error() string
type RequestQueryHook ¶
RequestQueryHook can be used to enforce redirect errors
type Result ¶
type Result struct { SearchMeta SearchMeta Hits []Document Suggestion []Suggestion Facets FacetCollection Promotions []Promotion Actions []Action }
Result defines a search result for one type
type SearchMeta ¶
type SearchMeta struct { Query string OriginalQuery string Page int NumPages int NumResults int SelectedFacets []Facet SortOptions []SortOption }
SearchMeta data
func (*SearchMeta) ValidatePageSize ¶
func (sm *SearchMeta) ValidatePageSize(pageSize int) error
ValidatePageSize checks if the pageSize is logical for current result
type SearchService ¶
type SearchService interface { // Types() []string Search(ctx context.Context, filter ...Filter) (results map[string]Result, err error) SearchFor(ctx context.Context, typ string, filter ...Filter) (result *Result, err error) }
SearchService defines how to access search
type SortFilter ¶
type SortFilter struct {
// contains filtered or unexported fields
}
SortFilter - specifies the request to sort by some criteria(label) in a certain direction. Possible values for label and direction should be in SearchMeta.SortOption
func NewSortFilter ¶
func NewSortFilter(label string, direction string) *SortFilter
NewSortFilter factory
func (*SortFilter) Descending ¶ added in v3.4.0
func (f *SortFilter) Descending() bool
Descending returns true if sort order is descending
func (*SortFilter) Direction ¶
func (f *SortFilter) Direction() string
Direction of the current filter
func (*SortFilter) Value ¶
func (f *SortFilter) Value() (string, []string)
Value of the current filter
type SortOption ¶
type SortOption struct { // Label that you normally want to show in the frontend (e.g. "Price") Label string // Field that you need to use in SearchRequest>SortFilter Field string // SelectedAsc true if sorting by this field is active SelectedAsc bool // SelectedDesc true if sorting by this field is active SelectedDesc bool // Asc - represents the field that is used to trigger ascending search. // Deprecated: use "Field" and "SelectedAsc" instead to set which field should be sortable Asc string // Desc - represents the field that is used to trigger descending search. // Deprecated: use "Field" and "SelectedDesc" instead to set which field should be sortable Desc string }
SortOption defines how sorting is possible, and which of them are activated with both an asc and desc option