xs

package
v0.0.0-...-8416b7a Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_WDF            = 0x3f
	MIXED_VNO          = 255
	TYPE_STRING        = 0
	TYPE_NUMERIC       = 1
	TYPE_DATE          = 2
	TYPE_ID            = 10
	TYPE_TITLE         = 11
	TYPE_BODY          = 12
	FLAG_INDEX_SELF    = 0x01
	FLAG_INDEX_MIXED   = 0x02
	FLAG_INDEX_BOTH    = 0x03
	FLAG_WITH_POSITION = 0x10
	FLAG_NON_BOOL      = 0x80
)
View Source
const (
	CMD_NONE                               = 0
	CMD_DEFAULT                            = 0
	CMD_PROTOCOL                           = 20110707
	CMD_USE                                = 1
	CMD_HELLO                              = 1
	CMD_DEBUG                              = 2
	CMD_TIMEOUT                            = 3
	CMD_QUIT                               = 4
	CMD_INDEX_SET_DB                       = 32
	CMD_INDEX_GET_DB                       = 33
	CMD_INDEX_SUBMIT                       = 34
	CMD_INDEX_REMOVE                       = 35
	CMD_INDEX_EXDATA                       = 36
	CMD_INDEX_CLEAN_DB                     = 37
	CMD_DELETE_PROJECT                     = 38
	CMD_INDEX_COMMIT                       = 39
	CMD_INDEX_REBUILD                      = 40
	CMD_FLUSH_LOGGING                      = 41
	CMD_INDEX_SYNONYMS                     = 42
	CMD_INDEX_USER_DICT                    = 43
	CMD_SEARCH_DB_TOTAL                    = 64
	CMD_SEARCH_GET_TOTAL                   = 65
	CMD_SEARCH_GET_RESULT                  = 66
	CMD_SEARCH_SET_DB                      = 32
	CMD_SEARCH_GET_DB                      = 33
	CMD_SEARCH_ADD_DB                      = 68
	CMD_SEARCH_FINISH                      = 69
	CMD_SEARCH_DRAW_TPOOL                  = 70
	CMD_SEARCH_ADD_LOG                     = 71
	CMD_SEARCH_GET_SYNONYMS                = 72
	CMD_SEARCH_SCWS_GET                    = 73
	CMD_QUERY_GET_STRING                   = 96
	CMD_QUERY_GET_TERMS                    = 97
	CMD_QUERY_GET_CORRECTED                = 98
	CMD_QUERY_GET_EXPANDED                 = 99
	CMD_OK                                 = 128
	CMD_ERR                                = 129
	CMD_SEARCH_RESULT_DOC                  = 140
	CMD_SEARCH_RESULT_FIELD                = 141
	CMD_SEARCH_RESULT_FACETS               = 142
	CMD_SEARCH_RESULT_MATCHED              = 143
	CMD_DOC_TERM                           = 160
	CMD_DOC_VALUE                          = 161
	CMD_DOC_INDEX                          = 162
	CMD_INDEX_REQUEST                      = 163
	CMD_IMPORT_HEADER                      = 191
	CMD_SEARCH_SET_SORT                    = 192
	CMD_SEARCH_SET_CUT                     = 193
	CMD_SEARCH_SET_NUMERIC                 = 194
	CMD_SEARCH_SET_COLLAPSE                = 195
	CMD_SEARCH_KEEPALIVE                   = 196
	CMD_SEARCH_SET_FACETS                  = 197
	CMD_SEARCH_SCWS_SET                    = 198
	CMD_SEARCH_SET_CUTOFF                  = 199
	CMD_SEARCH_SET_MISC                    = 200
	CMD_QUERY_INIT                         = 224
	CMD_QUERY_PARSE                        = 225
	CMD_QUERY_TERM                         = 226
	CMD_QUERY_TERMS                        = 232
	CMD_QUERY_RANGEPROC                    = 227
	CMD_QUERY_RANGE                        = 228
	CMD_QUERY_VALCMP                       = 229
	CMD_QUERY_PREFIX                       = 230
	CMD_QUERY_PARSEFLAG                    = 231
	CMD_SORT_TYPE_RELEVANCE                = 0
	CMD_SORT_TYPE_DOCID                    = 1
	CMD_SORT_TYPE_VALUE                    = 2
	CMD_SORT_TYPE_MULTI                    = 3
	CMD_SORT_TYPE_GEODIST                  = 4
	CMD_SORT_TYPE_MASK                     = 0x3f
	CMD_SORT_FLAG_RELEVANCE                = 0x40
	CMD_SORT_FLAG_ASCENDING                = 0x80
	CMD_QUERY_OP_AND                       = 0
	CMD_QUERY_OP_OR                        = 1
	CMD_QUERY_OP_AND_NOT                   = 2
	CMD_QUERY_OP_XOR                       = 3
	CMD_QUERY_OP_AND_MAYBE                 = 4
	CMD_QUERY_OP_FILTER                    = 5
	CMD_RANGE_PROC_STRING                  = 0
	CMD_RANGE_PROC_DATE                    = 1
	CMD_RANGE_PROC_NUMBER                  = 2
	CMD_VALCMP_LE                          = 0
	CMD_VALCMP_GE                          = 1
	CMD_PARSE_FLAG_BOOLEAN                 = 1
	CMD_PARSE_FLAG_PHRASE                  = 2
	CMD_PARSE_FLAG_LOVEHATE                = 4
	CMD_PARSE_FLAG_BOOLEAN_ANY_CASE        = 8
	CMD_PARSE_FLAG_WILDCARD                = 16
	CMD_PARSE_FLAG_PURE_NOT                = 32
	CMD_PARSE_FLAG_PARTIAL                 = 64
	CMD_PARSE_FLAG_SPELLING_CORRECTION     = 128
	CMD_PARSE_FLAG_SYNONYM                 = 256
	CMD_PARSE_FLAG_AUTO_SYNONYMS           = 512
	CMD_PARSE_FLAG_AUTO_MULTIWORD_SYNONYMS = 1536
	CMD_PREFIX_NORMAL                      = 0
	CMD_PREFIX_BOOLEAN                     = 1
	CMD_INDEX_WEIGHT_MASK                  = 0x3f
	CMD_INDEX_FLAG_WITHPOS                 = 0x40
	CMD_INDEX_FLAG_SAVEVALUE               = 0x80
	CMD_INDEX_FLAG_CHECKSTEM               = 0x80
	CMD_VALUE_FLAG_NUMERIC                 = 0x80
	CMD_INDEX_REQUEST_ADD                  = 0
	CMD_INDEX_REQUEST_UPDATE               = 1
	CMD_INDEX_SYNONYMS_ADD                 = 0
	CMD_INDEX_SYNONYMS_DEL                 = 1
	CMD_SEARCH_MISC_SYN_SCALE              = 1
	CMD_SEARCH_MISC_MATCHED_TERM           = 2
	CMD_SEARCH_MISC_WEIGHT_SCHEME          = 3
	CMD_SCWS_GET_VERSION                   = 1
	CMD_SCWS_GET_RESULT                    = 2
	CMD_SCWS_GET_TOPS                      = 3
	CMD_SCWS_HAS_WORD                      = 4
	CMD_SCWS_GET_MULTI                     = 5
	CMD_SCWS_SET_IGNORE                    = 50
	CMD_SCWS_SET_MULTI                     = 51
	CMD_SCWS_SET_DUALITY                   = 52
	CMD_SCWS_SET_DICT                      = 53
	CMD_SCWS_ADD_DICT                      = 54
	CMD_ERR_UNKNOWN                        = 600
	CMD_ERR_NOPROJECT                      = 401
	CMD_ERR_TOOLONG                        = 402
	CMD_ERR_INVALIDCHAR                    = 403
	CMD_ERR_EMPTY                          = 404
	CMD_ERR_NOACTION                       = 405
	CMD_ERR_RUNNING                        = 406
	CMD_ERR_REBUILDING                     = 407
	CMD_ERR_WRONGPLACE                     = 450
	CMD_ERR_WRONGFORMAT                    = 451
	CMD_ERR_EMPTYQUERY                     = 452
	CMD_ERR_TIMEOUT                        = 501
	CMD_ERR_IOERR                          = 502
	CMD_ERR_NOMEM                          = 503
	CMD_ERR_BUSY                           = 504
	CMD_ERR_UNIMP                          = 505
	CMD_ERR_NODB                           = 506
	CMD_ERR_DBLOCKED                       = 507
	CMD_ERR_CREATE_HOME                    = 508
	CMD_ERR_INVALID_HOME                   = 509
	CMD_ERR_REMOVE_HOME                    = 510
	CMD_ERR_REMOVE_DB                      = 511
	CMD_ERR_STAT                           = 512
	CMD_ERR_OPEN_FILE                      = 513
	CMD_ERR_TASK_CANCELED                  = 514
	CMD_ERR_XAPIAN                         = 515
	CMD_OK_INFO                            = 200
	CMD_OK_PROJECT                         = 201
	CMD_OK_QUERY_STRING                    = 202
	CMD_OK_DB_TOTAL                        = 203
	CMD_OK_QUERY_TERMS                     = 204
	CMD_OK_QUERY_CORRECTED                 = 205
	CMD_OK_SEARCH_TOTAL                    = 206
	CMD_OK_RESULT_BEGIN                    = 206
	CMD_OK_RESULT_END                      = 207
	CMD_OK_TIMEOUT_SET                     = 208
	CMD_OK_FINISHED                        = 209
	CMD_OK_LOGGED                          = 210
	CMD_OK_RQST_FINISHED                   = 250
	CMD_OK_DB_CHANGED                      = 251
	CMD_OK_DB_INFO                         = 252
	CMD_OK_DB_CLEAN                        = 253
	CMD_OK_PROJECT_ADD                     = 254
	CMD_OK_PROJECT_DEL                     = 255
	CMD_OK_DB_COMMITED                     = 256
	CMD_OK_DB_REBUILD                      = 257
	CMD_OK_LOG_FLUSHED                     = 258
	CMD_OK_DICT_SAVED                      = 259
	CMD_OK_RESULT_SYNONYMS                 = 280
	CMD_OK_SCWS_RESULT                     = 290
	CMD_OK_SCWS_TOPS                       = 291
)
View Source
const (
	DocResSize   int    = 20
	DocResFormat string = "IdocId/Irank/Icount/ipercent/fweight"
)

DocResSize is the len of the doc buf

Variables

This section is empty.

Functions

func Pack

func Pack(format string, args ...interface{}) (string, error)

Pack date into String

func UnPack

func UnPack(format, data string) (map[string]interface{}, error)

Types

type Command

type Command struct {
	Cmd  uint8
	Arg1 uint8  //其值为 0~255, 具体含义视不同 CMD 而确定
	Arg2 uint8  //其值为 0~255, 具体含义视不同 CMD 而确定, 常用于存储 value no
	Buf  string //字符串内容, 最大长度为 2GB
	Buf1 string //字符串内容1, 最大长度为 255字节
}

func NewCommand

func NewCommand(cmd uint8, arg1 uint8, arg2 uint8, buf ...string) *Command

func (*Command) Encode

func (command *Command) Encode(bigEndian bool) []byte

func (*Command) GetArg

func (command *Command) GetArg() uint16

GetArg return the the

func (*Command) SetArg

func (command *Command) SetArg(arg uint16)

SetArg sets the arg1 and arg2 by on value

type Connection

type Connection struct {
	IsBigEndian bool
	// contains filtered or unexported fields
}

Connection to indexer or searcher server

func NewConnection

func NewConnection(addr string) (*Connection, error)

NewConnection to server

func (*Connection) Close

func (connection *Connection) Close()

Close the connection

func (*Connection) Exec

func (connection *Connection) Exec(command *Command) (*Command, error)

func (*Connection) ExecBatch

func (connection *Connection) ExecBatch(commands []*Command) (*Command, error)

func (*Connection) GetResponse

func (connection *Connection) GetResponse() (*Command, error)

func (*Connection) SetProjectName

func (connection *Connection) SetProjectName(name string) error

type Document

type Document struct {
	Fields  map[string]string `json:"fields"`
	DocId   uint32            `json:"docId"`
	Rank    uint32            `json:"rank"`
	Count   uint32            `json:"count"`
	Percent int32             `json:"percent"`
	Weight  float32           `json:"weight"`
	Matched []string          `json:"matched"`
}

Document for search result

func NewDocument

func NewDocument(meta string) (*Document, error)

NewDocument creates document instance from meta

type Field

type Field struct {
	Vno       uint8
	Name      string
	Type      string
	Index     string
	Weight    uint16
	CutLen    uint16
	Flag      int
	Tokenizer string
}

func (*Field) HasIndex

func (field *Field) HasIndex() bool

func (*Field) HasIndexMixed

func (field *Field) HasIndexMixed() bool

func (*Field) HasIndexSelf

func (field *Field) HasIndexSelf() bool

func (*Field) IsBoolIndex

func (field *Field) IsBoolIndex() bool

func (*Field) IsNumeric

func (field *Field) IsNumeric() bool

func (*Field) IsSpecial

func (field *Field) IsSpecial() bool

func (*Field) WithPos

func (field *Field) WithPos() bool

type Schema

type Schema struct {
	Id     *Field
	Title  *Field
	Body   *Field
	Fields map[uint8]*Field
}

Schema of Document to be indexed

func (*Schema) GetFieldDict

func (schema *Schema) GetFieldDict() map[string]*Field

type Setting

type Setting struct {
	ProjectName           string
	ProjectDefaultCharset string
	IndexServer           string
	SearchServer          string
	Schema                *Schema
}

func NewSetting

func NewSetting(ini string) *Setting

Jump to

Keyboard shortcuts

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