indices

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const MarkIndexMapping = `` /* 737-byte string literal not displayed */
View Source
const MarkIndexName = "marks"

Variables

View Source
var Enable bool // if not, jump ES processing
View Source
var NotEnabledError = fmt.Errorf("es is not enabled yet")

Functions

func Client

func Client() *elastic.Client

func IndexName

func IndexName(name string) string

func MarkIndexDelete

func MarkIndexDelete(markID uint) (*elastic.DeleteResponse, error)

func Ping

func Ping()

Ping and init indices

func SetupMarkIndex

func SetupMarkIndex() error

Types

type CommentIndex

type CommentIndex struct {
	Comment string `json:"comment"`
	// contains filtered or unexported fields
}

CommentIndex is part of MarkIndex. Only update CommentIndex on existed MarkIndex.

func NewCommentIndex

func NewCommentIndex(c *models.Comment) *CommentIndex

func (*CommentIndex) Update

func (commentIndex *CommentIndex) Update() (*elastic.UpdateResponse, error)

POST /mark/_update/:markID

{
  "doc": {
    "comment": "actually"
  }
}

type MarkIndex

type MarkIndex struct {
	ID        uint      `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	UserID    uint   `json:"user_id"`
	URL       string `json:"url"`
	Tag       string `json:"tag"`
	HashKey   string `json:"hash_key"`
	Selection string `json:"selection"`
	Comment   string `json:"comment"`
	// contains filtered or unexported fields
}

func NewMarkIndex

func NewMarkIndex(m *models.Mark) (markIndex *MarkIndex)

func Query

func Query(u *models.User, text string) (marks []*MarkIndex)

* GET /mark/_search

{
  "query": {
    "bool": {
      "filter": {
        "term": {
          "user_id": 1
        }
      },
      "minimum_should_match": "1",
      "should": [
        {
          "match": {
            "selection": {
              "query": "like"
            }
          }
        },
        {
          "match": {
            "comment": {
              "query": "like"
            }
          }
        }
      ]
    }
  },
  "sort": [
    {
      "id": {
        "order": "desc"
      }
    }
  ]
}

func (*MarkIndex) Fresh

func (m *MarkIndex) Fresh() (*elastic.IndexResponse, error)

type SetupMethod

type SetupMethod func() error

Jump to

Keyboard shortcuts

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