XU XUv0.8.8
EN

API

#github.com/xulang-org/packages/elasticsearch

import: elasticsearch #github.com/xulang-org/packages/elasticsearch

counts: 4 函数, 25 方法, 5 类型, 0 常量, 0 方法集

扩展包 `elasticsearch #github.com/xulang-org/packages/elasticsearch`,由模块 github.com/xulang-org/packages 提供。

github.com/xulang-org/packages · 0.1.1 · 安装与使用

open

XuAPI
pub fn open(endpoint string) Client

用途

打开。

参数

endpoint string
endpoint(string)

返回

Client — 该类型的值

open_pool

XuAPI
pub fn open_pool(endpoint string, max_idle int) Pool

用途

打开pool。

参数

endpoint string
endpoint(string)
max_idle int
max_idle(int)

返回

Pool — 该类型的值

struct Response

XuAPI
pub struct Response {
    pub status_code int
    pub body string
}

用途

公开结构体 `Response`。

参数

status_code int
字段(int)
body string
正文

struct Client

XuAPI
pub struct Client {
    pub host string
    pub port int
}

用途

公开结构体 `Client`。

参数

host string
主机
port int
端口

new_client

XuAPI
pub fn new_client(endpoint string) Client

用途

构造 client。

参数

endpoint string
endpoint(string)

返回

Client — 该类型的值

(&mut Client) request

XuAPI
pub fn (c &mut Client) request(method string, path string, body string) Response

用途

`&mut Client` 上的方法:请求。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
method string
method(string)
path string
文件系统路径(string)
body string
正文(string)

返回

Response — 该类型的值

(&mut Client) ping

XuAPI
pub fn (c &mut Client) ping() bool

用途

在 `&mut Client` 上调用 `ping`。

参数

c &mut Client
接收者 &mut Client(可变借用)

返回

bool — 是否成立

(&mut Client) info

XuAPI
pub fn (c &mut Client) info() string

用途

在 `&mut Client` 上调用 `info`。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)

返回

string — 结果字符串

(&mut Client) index_doc

XuAPI
pub fn (c &mut Client) index_doc(index string, id string, doc_json string) string

用途

`&mut Client` 上的方法:下标doc。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
index string
index(string)
id string
id(string)
doc_json string
doc_json(string)

返回

string — 结果字符串

(&mut Client) get_doc

XuAPI
pub fn (c &mut Client) get_doc(index string, id string) string

用途

`&mut Client` 上的方法:读取 doc。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
index string
index(string)
id string
id(string)

返回

string — 结果字符串

(&mut Client) delete_doc

XuAPI
pub fn (c &mut Client) delete_doc(index string, id string) bool

用途

`&mut Client` 上的方法:删除doc。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
index string
index(string)
id string
id(string)

返回

bool — 是否成立

(&mut Client) update_doc

XuAPI
pub fn (c &mut Client) update_doc(index string, id string, doc_json string) bool

用途

`&mut Client` 上的方法:更新doc。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
index string
index(string)
id string
id(string)
doc_json string
doc_json(string)

返回

bool — 是否成立

(&mut Client) create_index

XuAPI
pub fn (c &mut Client) create_index(index string, mapping_json string) bool

用途

`&mut Client` 上的方法:创建下标。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
index string
index(string)
mapping_json string
mapping_json(string)

返回

bool — 是否成立

(&mut Client) delete_index

XuAPI
pub fn (c &mut Client) delete_index(index string) bool

用途

`&mut Client` 上的方法:删除下标。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
index string
index(string)

返回

bool — 是否成立

(&mut Client) index_exists

XuAPI
pub fn (c &mut Client) index_exists(index string) bool

用途

`&mut Client` 上的方法:下标exists。

参数

c &mut Client
接收者 &mut Client(可变借用)
index string
index(string)

返回

bool — 是否成立

(&mut Client) refresh

XuAPI
pub fn (c &mut Client) refresh(index string) bool

用途

在 `&mut Client` 上调用 `refresh`。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
index string
index(string)

返回

bool — 是否成立

struct Pool

XuAPI
pub struct Pool {
    pub host string
    pub port int
    pub endpoint string
    pub state chan pool.State
    pub max_idle int
}

用途

公开结构体 `Pool`。

参数

host string
主机
port int
端口
endpoint string
字段(string)
state chan pool.State
字段(通道;类型 chan pool.State)
max_idle int
字段(int)

new_pool

XuAPI
pub fn new_pool(endpoint string, max_idle int) Pool

用途

构造 pool。

参数

endpoint string
endpoint(string)
max_idle int
max_idle(int)

返回

Pool — 该类型的值

(&Pool) get

XuAPI
pub fn (p &Pool) get() Client

用途

在 `&Pool` 上调用 `get`。

参数

p &Pool
接收者 &Pool(借用)

返回

Client — 该类型的值

(&Pool) dup

XuAPI
pub fn (p &Pool) dup() Pool

用途

在 `&Pool` 上调用 `dup`。

参数

p &Pool
接收者 &Pool(借用)

返回

Pool — 该类型的值

(&Pool) get_conn

XuAPI
pub fn (p &Pool) get_conn() int

用途

`&Pool` 上的方法:读取 conn。

参数

p &Pool
接收者 &Pool(借用)

返回

int — 该类型的值

(&Pool) put_conn

XuAPI
pub fn (p &Pool) put_conn(fd int)

用途

`&Pool` 上的方法:put连接。

参数

p &Pool
接收者 &Pool(借用)
fd int
文件描述符(int)

(&Pool) discard_conn

XuAPI
pub fn (p &Pool) discard_conn(fd int)

用途

`&Pool` 上的方法:丢弃连接。

参数

p &Pool
接收者 &Pool(借用)
fd int
文件描述符(int)

(&Pool) search_match

XuAPI
pub fn (p &Pool) search_match(index string, field string, query_text string) SearchResult

用途

`&Pool` 上的方法:二分查找match。失败时 throw。

参数

p &Pool
接收者 &Pool(借用)
index string
index(string)
field string
field(string)
query_text string
query_text(string)

返回

SearchResult — 该类型的值

(&Pool) get_doc

XuAPI
pub fn (p &Pool) get_doc(index string, id string) string

用途

`&Pool` 上的方法:读取 doc。失败时 throw。

参数

p &Pool
接收者 &Pool(借用)
index string
index(string)
id string
id(string)

返回

string — 结果字符串

(&Pool) index_doc

XuAPI
pub fn (p &Pool) index_doc(index string, id string, doc_json string) string

用途

`&Pool` 上的方法:下标doc。失败时 throw。

参数

p &Pool
接收者 &Pool(借用)
index string
index(string)
id string
id(string)
doc_json string
doc_json(string)

返回

string — 结果字符串

(&Pool) delete_doc

XuAPI
pub fn (p &Pool) delete_doc(index string, id string) bool

用途

`&Pool` 上的方法:删除doc。失败时 throw。

参数

p &Pool
接收者 &Pool(借用)
index string
index(string)
id string
id(string)

返回

bool — 是否成立

(&Pool) ping

XuAPI
pub fn (p &Pool) ping() bool

用途

在 `&Pool` 上调用 `ping`。

参数

p &Pool
接收者 &Pool(借用)

返回

bool — 是否成立

(&Pool) close

XuAPI
pub fn (p &Pool) close()

用途

`&Pool` 上的方法:关闭资源。

参数

p &Pool
接收者 &Pool(借用)

struct SearchHit

XuAPI
pub struct SearchHit {
    pub id string
    pub score string
    pub source string
}

用途

公开结构体 `SearchHit`。

参数

id string
字段(string)
score string
字段(string)
source string
字段(string)

struct SearchResult

XuAPI
pub struct SearchResult {
    pub total int
    pub raw_json string
    pub hits []SearchHit
}

用途

公开结构体 `SearchResult`。

参数

total int
字段(int)
raw_json string
字段(string)
hits []SearchHit
字段([]SearchHit)

(&mut Client) search_match

XuAPI
pub fn (c &mut Client) search_match(index string, field string, query_text string) SearchResult

用途

`&mut Client` 上的方法:二分查找match。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
index string
index(string)
field string
field(string)
query_text string
query_text(string)

返回

SearchResult — 该类型的值