Documentation ¶
Index ¶
- Constants
- func CreateIndex(es *esapi.IndicesCreate, indexName string, mappings map[string]any) error
- func DeleteDocument(es *esapi.DeleteByQuery, esSQLTranslate *esapi.SQLTranslate, ...) (int, error)
- func DeleteIndex(es *esapi.IndicesDelete, indexName string) error
- func IndexDocument(es *esapi.Index, inputStruct IndexInput) error
- func Init(bc base.Component) *component
- func MultiIndexDocument(es *esapi.Bulk, inputStruct MultiIndexInput) (int, error)
- func UpdateDocument(es *esapi.UpdateByQuery, esSQLTranslate *esapi.SQLTranslate, ...) (int, error)
- type CountResponse
- type CreateIndexInput
- type CreateIndexOutput
- type DeleteIndexInput
- type DeleteIndexOutput
- type DeleteInput
- type DeleteOutput
- type DeleteUpdateResponse
- type ESBulk
- type ESClient
- type ESCount
- type ESCreateIndex
- type ESDelete
- type ESDeleteIndex
- type ESIndex
- type ESSQLTranslate
- type ESSearch
- type ESUpdate
- type Hit
- type IndexInput
- type IndexOutput
- type MultiIndexInput
- type MultiIndexOutput
- type MultiIndexResponse
- type SearchInput
- type SearchOutput
- type SearchResponse
- type SearchResult
- type UpdateInput
- type UpdateOutput
- type VectorResult
- type VectorSearchInput
- type VectorSearchOutput
Constants ¶
const ( TaskSearch = "TASK_SEARCH" TaskVectorSearch = "TASK_VECTOR_SEARCH" TaskIndex = "TASK_INDEX" TaskMultiIndex = "TASK_MULTI_INDEX" TaskUpdate = "TASK_UPDATE" TaskDelete = "TASK_DELETE" TaskCreateIndex = "TASK_CREATE_INDEX" TaskDeleteIndex = "TASK_DELETE_INDEX" )
Variables ¶
This section is empty.
Functions ¶
func CreateIndex ¶
mappings refer to elasticsearch documentation for more information, use dense_vector type with similarity and dims fields pre-defined mappings is mandatory for vector search, if index isnt created with mappings, vector search will not work as dense_vector type doesn't explicitly defined
func DeleteDocument ¶
func DeleteDocument(es *esapi.DeleteByQuery, esSQLTranslate *esapi.SQLTranslate, inputStruct DeleteInput) (int, error)
func DeleteIndex ¶
func DeleteIndex(es *esapi.IndicesDelete, indexName string) error
func IndexDocument ¶
func IndexDocument(es *esapi.Index, inputStruct IndexInput) error
func MultiIndexDocument ¶
func MultiIndexDocument(es *esapi.Bulk, inputStruct MultiIndexInput) (int, error)
func UpdateDocument ¶
func UpdateDocument(es *esapi.UpdateByQuery, esSQLTranslate *esapi.SQLTranslate, inputStruct UpdateInput) (int, error)
Types ¶
type CountResponse ¶
type CountResponse struct {
Count int `json:"count"`
}
type CreateIndexInput ¶
type CreateIndexOutput ¶
type CreateIndexOutput struct {
Status string `json:"status"`
}
type DeleteIndexInput ¶
type DeleteIndexInput struct {
IndexName string `json:"index-name"`
}
type DeleteIndexOutput ¶
type DeleteIndexOutput struct {
Status string `json:"status"`
}
type DeleteInput ¶
type DeleteOutput ¶
type DeleteOutput struct {
Status string `json:"status"`
}
type DeleteUpdateResponse ¶
type ESCreateIndex ¶
type ESDeleteIndex ¶
type ESSQLTranslate ¶
type Hit ¶
type Hit struct { Index string `json:"_index"` ID string `json:"_id"` Score float64 `json:"_score"` Source map[string]any `json:"_source"` }
func SearchDocument ¶
func SearchDocument(es *esapi.Search, esSQLTranslate *esapi.SQLTranslate, inputStruct SearchInput) ([]Hit, error)
size is optional, empty means all documents min-score is optional, empty means no minimum score fields is optional, empty means all fields filter is optional, empty means no filter, choose one (id, filter, or filter-sql) id is optional, empty means no id, choose one (id, filter, or filter-sql) filter-sql is optional, empty means no filter-sql, choose one (id, filter, or filter-sql) query is optional, empty means no query, only for full text search
func VectorSearchDocument ¶
func VectorSearchDocument(es *esapi.Search, esSQLTranslate *esapi.SQLTranslate, inputStruct VectorSearchInput) ([]Hit, error)
Only support vector search for now, for semantic search, we can use external model on other component combined with vector search size is optional, empty means all documents source-only, if true will return only source of documents, if false will return all fields (_id, _index, _score, _source) min-score is optional, empty means no minimum score fields is optional, empty means all fields filter is optional, empty means no filter
type IndexInput ¶
type IndexOutput ¶
type IndexOutput struct {
Status string `json:"status"`
}
type MultiIndexInput ¶
type MultiIndexOutput ¶
type MultiIndexOutput struct {
Status string `json:"status"`
}
type MultiIndexResponse ¶
type SearchInput ¶
type SearchOutput ¶
type SearchOutput struct { Result SearchResult `json:"result"` Status string `json:"status"` }
type SearchResponse ¶
type SearchResponse struct { Took int `json:"took"` TimedOut bool `json:"timed_out"` Shards struct { Total int `json:"total"` Successful int `json:"successful"` Skipped int `json:"skipped"` Failed int `json:"failed"` } `json:"_shards"` Hits struct { Total struct { Value int `json:"value"` Relation string `json:"relation"` } `json:"total"` MaxScore float64 `json:"max_score"` Hits []Hit `json:"hits"` } `json:"hits"` }
type SearchResult ¶
type UpdateInput ¶
type UpdateOutput ¶
type UpdateOutput struct {
Status string `json:"status"`
}
type VectorResult ¶
type VectorSearchInput ¶
type VectorSearchInput struct { Filter map[string]any `json:"filter"` FilterSQL string `json:"filter-sql"` IndexName string `json:"index-name"` Field string `json:"field"` Fields []string `json:"fields"` QueryVector []float64 `json:"query-vector"` K int `json:"k"` NumCandidates int `json:"num-candidates"` MinScore float64 `json:"min-score"` }
type VectorSearchOutput ¶
type VectorSearchOutput struct { Status string `json:"status"` Result VectorResult `json:"result"` }