Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ES function #1886

Merged
merged 17 commits into from
Jun 30, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,4 @@ nebula> LOOKUP ON player WHERE FUZZY(player.name, "Tim Dunncan", AUTO, OR) YIELD
//删除全文索引。
nebula> DROP FULLTEXT INDEX nebula_index_1;
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Elasticsearch 查询函数

对于原生的 ES 服务,calles() 函数可以通过 GET 请求执行复杂的查询语句查询其中的数据。

关于 ES 语法,请参见 [ES 官方文档](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-your-data.html)。
cooper-lzy marked this conversation as resolved.
Show resolved Hide resolved

!!! enterpriseonly

仅企业版支持本功能。

## 注意事项

- 需要自行搭建原生 ES 服务,如果需要数据同步请自行实现,不能使用部署了全文索引的 ES 服务。部署 Elasticsearch 集群请参见 [Kubernetes 安装 Elasticsearch](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-deploy-elasticsearch.html) 或[单机安装 Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/7.15/targz.html)。

- 使用前需要登录文本搜索客户端(`SIGN IN TEXT SERVICE`),请填写原生 ES 服务的 IP 和端口。命令请参见[登录文本搜索客户端](../../4.deployment-and-installation/6.deploy-text-based-index/2.deploy-es.md#_3)。

- calles() 函数只支持 GET 请求。请用 ES 原生客户端执行 POST、PUT、DELETE 请求。

## 语法

```ngql
calles("<es_query>");
```

- 返回类型:map。

## 示例

```ngql
nebula> WITH calles("test/player/1") AS a RETURN a;
cooper-lzy marked this conversation as resolved.
Show resolved Hide resolved
+---------------------------------------------------------------------------------------------------------------------------------------------+
| a |
+---------------------------------------------------------------------------------------------------------------------------------------------+
| {_id: "1", _index: "test", _primary_term: 1, _seq_no: 0, _source: {age: 43, name: "Tim Duncan"}, _type: "player", _version: 1, found: true} |
+---------------------------------------------------------------------------------------------------------------------------------------------+

nebula> WITH calles("test/player/1") AS a MATCH (b:player) WHERE b.player.age == a["_source"]["age"] RETURN b;
cooper-lzy marked this conversation as resolved.
Show resolved Hide resolved
+---------------------------------------------------+
| b |
+---------------------------------------------------+
| ("player141" :player{age: 43, name: "Ray Allen"}) |
+---------------------------------------------------+
cooper-lzy marked this conversation as resolved.
Show resolved Hide resolved
```
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

- 全文索引不支持搜索属性值为`NULL`的属性。

- 写入数据时,Elastic Search 会自动创建相应的索引。在 Nebula Graph 中创建全文索引,但是未写入数据,查询时会报错`text search not found`。
cooper-lzy marked this conversation as resolved.
Show resolved Hide resolved

- 不支持修改 Elastic Search 中的索引,只能删除重建。
cooper-lzy marked this conversation as resolved.
Show resolved Hide resolved

- 不支持管道符。
Expand All @@ -37,3 +39,5 @@
- 从写入 Nebula Graph,到写入 listener,再到写入 Elasticsearch 并创建索引可能需要一段时间。如果访问全文索引时返回未找到索引,可等待索引生效(但是,该等待时间未知,也无返回码检查)。

- 使用 K8s 方式部署的 Nebula Graph 集群不支持全文索引。

- 不能与 [calles()](../../3.ngql-guide/6.functions-and-expressions/17.ES-function.md) 函数同时使用。