suggest

package
v0.0.0-...-c5d5a31 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Overview

Package suggest handles AutoComplete and Phrase Suggester (Did you mean?) queries

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Naughty

func Naughty(s string) bool

Naughty indicates if a word or phrase is NSFW

func NewNaughty

func NewNaughty(fh string) error

NewNaughty loads our naughty list

Types

type ElasticSearch

type ElasticSearch struct {
	Client *elastic.Client
	Index  string
	Type   string
}

ElasticSearch holds the index name and the connection

func (*ElasticSearch) Completion

func (e *ElasticSearch) Completion(term string, size int) (Results, error)

Completion handles autocomplete queries

func (*ElasticSearch) Exists

func (e *ElasticSearch) Exists(term string) (bool, error)

Exists checks if a term is already in our index

func (*ElasticSearch) Increment

func (e *ElasticSearch) Increment(term string) error

Increment increments a term in our index

func (*ElasticSearch) IndexExists

func (e *ElasticSearch) IndexExists() (bool, error)

IndexExists returns true if the index exists

func (*ElasticSearch) Insert

func (e *ElasticSearch) Insert(term string) error

Insert adds a new term to our index

func (*ElasticSearch) Setup

func (e *ElasticSearch) Setup() error

Setup creates a completion index

type Results

type Results struct {
	Suggestions []string `json:"suggestions"`
}

Results are the results of an autocomplete query

type Simple

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

Simple is a simple autocomplete suggester

func (*Simple) Completion

func (s *Simple) Completion(term string, size int) (Results, error)

Completion handles autocomplete queries

func (*Simple) Exists

func (s *Simple) Exists(term string) (bool, error)

Exists checks if a term is already in our index

func (*Simple) Increment

func (s *Simple) Increment(term string) error

Increment increments a term in our index

func (*Simple) IndexExists

func (s *Simple) IndexExists() (bool, error)

IndexExists returns true if the index exists

func (*Simple) Insert

func (s *Simple) Insert(term string) error

Insert adds a new term to our index

func (*Simple) Setup

func (s *Simple) Setup() error

Setup creates a completion index

type Suggester

type Suggester interface {
	IndexExists() (bool, error)
	Setup() error
	Exists(q string) (bool, error)
	Insert(q string) error
	Increment(q string) error
	Completion(q string, size int) (Results, error)
}

Suggester outlines methods to fetch & store Autocomplete & PhraseSuggester results

Jump to

Keyboard shortcuts

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