module

package
v0.0.0-...-683a4be Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2020 License: GPL-3.0 Imports: 10 Imported by: 2

Documentation

Overview

Package module is the core package of elasthink

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitModule

func InitModule(stopwordData entity.StopwordData, redisObject *redis.Redis, stopwordRemovalUsage bool)

InitModule is a function that initializes a module object and its requirements (dependencies)

Types

type CreateIndexRequestPayload

type CreateIndexRequestPayload struct {
	DocumentName string `json:"documentName"`
}

CreateIndexRequestPayload is the universal request payload for create index handler

type KeywordSuggestionResponsePayload

type KeywordSuggestionResponsePayload struct {
	SortedKeywords []string `json:"sortedKeywords"`
}

KeywordSuggestionResponsePayload is the universal response payload for keyword suggestion API handler

type Module

type Module struct {
	StopwordSet            map[string]int
	Redis                  *redis.Redis
	IsUsingStopwordRemoval bool
}

Module is the main struct to represent a core module

type RankByShowCount

type RankByShowCount []entity.SearchResultRankData

RankByShowCount is the additional struct for document ranking purpose based on its ShowCount

func (RankByShowCount) Len

func (r RankByShowCount) Len() int

func (RankByShowCount) Less

func (r RankByShowCount) Less(i, j int) bool

func (RankByShowCount) Swap

func (r RankByShowCount) Swap(i, j int)

type Response

type Response struct {
	StatusCode   int
	ErrorMessage string
	Data         interface{}
}

Response is the universal response struct for all API

func CreateIndex

func CreateIndex(ctx context.Context, documentID int64, documentType string, requestPayload CreateIndexRequestPayload) Response

CreateIndex is the core function to create an index of a document

func Search(ctx context.Context, documentType string, requestPayload SearchRequestPayload) Response

Search is the core function of searching a document

func SuggestKeywords

func SuggestKeywords(ctx context.Context, documentType, prefix string) Response

SuggestKeywords is the core function for keyword suggestion (by document type and prefix)

func UpdateIndex

func UpdateIndex(ctx context.Context, documentID int64, documentType string, requestPayload UpdateIndexRequestPayload) Response

UpdateIndex is the core function to update the index of a document. This requires old document name and new document name

type SearchRequestPayload

type SearchRequestPayload struct {
	SearchTerm string `json:"searchTerm"`
}

SearchRequestPayload is the universal request payload for search handlers

type SearchResponsePayload

type SearchResponsePayload struct {
	RankedResultList []entity.SearchResultRankData `json:"rankedResultList"`
}

SearchResponsePayload is the universal response payload for search handlers

type UpdateIndexRequestPayload

type UpdateIndexRequestPayload struct {
	OldDocumentName string `json:"oldDocumentName"`
	NewDocumentName string `json:"newDocumentName"`
}

UpdateIndexRequestPayload is the universal request payload for update index handler

Jump to

Keyboard shortcuts

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