Skip to content

Commit

Permalink
doc: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahoo-Wang committed Nov 10, 2023
1 parent e8ebb4d commit a943ee8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Velocity for Elasticsearch

*Search Template* is a highly valuable feature in Elasticsearch. It allows the pre-definition of the query structure for search requests, with the ability to pass search parameters during the actual request. This not only makes the request body more concise but also helps avoid errors that may occur when concatenating query structures on the client side.

When search optimization is necessary, modifications to search scripts can be made directly on the Elasticsearch server without the need to redeploy the client. This significantly enhances the efficiency of search optimization.

However, the [default scripting languages](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html#scripting-available-languages) (`mustache`/`painless`/`expression`) supported by *Elasticsearch* have relatively limited syntax logic, lacking support for any conditional statements. This imposes significant constraints on the use of *Search Template*.

By introducing *Velocity* into *Elasticsearch*, support for any conditional statements is enabled, making the usage of *Search Template* more flexible. This provides users with greater customization capabilities for powerful and flexible searches.

## Install

> optional 1 - use elasticsearch-plugin to install
Expand Down
10 changes: 8 additions & 2 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Velocity for Elasticsearch

*Search Template**Elasticsearch* 中一项非常实用的功能。通过这一特性,搜索请求的查询结构可以事先定义好,然后在实际请求时传入搜索参数。这样既使得请求体更加简洁,也避免了在客户端拼接查询结构时可能出现的错误。

在需要进行搜索调优时,可以直接在 *Elasticsearch* 服务端修改搜索脚本,而无需重新发布客户端。这显著提高了搜索调优的效率。

然而,*Elasticsearch* [默认支持的脚本语言](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html#scripting-available-languages)`mustache`/`painless`/`expression`)的语法逻辑相对较为有限,不支持逻辑判断,从而对 *Search Template* 的使用带来了一定的限制。

通过引入 *Velocity**Elasticsearch* 中,可以支持任何逻辑判断,使得 *Search Template* 的使用更加灵活。这为用户提供了更强大、更灵活的搜索定制能力。

## 安装

> 方式 1 - 使用 `elasticsearch-plugin `安装
Expand All @@ -19,8 +27,6 @@

[create-stored-script-api](https://www.elastic.co/guide/en/elasticsearch/reference/current/create-stored-script-api.html)

```http request
```http request
POST _scripts/templateid
{
Expand Down

0 comments on commit a943ee8

Please sign in to comment.