RediSearch 1.2 发行说明
聚合筛选条件。Query 属性。模糊匹配。条件更新。反斜杠转义。同义词支持。
Redis 堆栈 |
---|
要求
RediSearch v1.2.0 需要:
- 最低 Redis 兼容版本(数据库):4.0.0
- 最低 Redis 企业软件版本(集群):5.0.0
RediSearch 1.2.0(2018 年 6 月)
这个版本是我(@dvirsky)将要发布的最后一个版本,它包含了很多很酷的新功能,实际上没有超过 1.1.0 的错误修复!这么久了,感谢所有的鱼!
新功能
聚合筛选条件
作为FT.AGGREGATE
,可以使用FILTER
关键词。例如:
FT.AGGREGATE idx "*"
GROUPBY 1 @foo
REDUCE count 0 AS num
FILTER "@num < 100"
See http://redisearch.io/Aggregations/ for more details.
Query attributes
It is now possible to apply specific query modifying attributes to specific clauses of the query (see #212).
The syntax is (foo bar) => { $attribute: value; $attribute:value; ...}
, e.g:
(foo bar) => { $weight: 2.0; $slop: 1 }
~(bar baz) => { $weight: 0.5; }
The supported attributes are:
- $weight: determines the weight of the sub-query or token in the overall ranking on the result.
- $slop: determines the maximum allowed "slop" (space between terms) in the query clause.
- $inorder: whether or not the terms in a query clause must appear in the same order as in the query.
Fuzzy matching
Wrapping a search term with %
will cause the index to expand the query to terms that are within an Edit Distance of 1 from the original term. For example, querying for %redis%
will expand it to query for redis, jedis, credis, predis
, etc (provided the terms appear in documents in the index).
Notice that each query term needs to be wrapped independently, and that we limit the maximum amount of expansions to 200 per term, as this hurts performance significantly.
Conditional updates
It is now possible to update documents (FT.ADD ... REPLACE [PARTIAL]
) only if a certain condition is met regarding the document's state before the updates. So for example, if our document has a timestamp field, and we would like to update its title only if the timestamp is below a certain value, we can do the following:
FT.ADD myIndex myDoc 1.0
REPLACE PARTIAL
IF "@timestamp < 12313134523"
FIELDS
title "new title"
Backslash escaping
Following several user requests, it is now possible to escape separator characters in documents (it is already done in the query itself), and avoid tokenization when needed.
For example, indexing the text hello\-world hello world
will create the tokenization ["hello-world", "hello", "world"]
. Notice that in most languages and in redis-cli, you will need to escape the backslash itself, so instead of hello\-world
you will need to send the string hello\\-world
.
The same goes to the query string: If the document contains the token hello-world
, it can be found by running in redis-cli: `FT.SEARCH idx "hello\-world", which will cause the query not to be separated.
Synonyms support
It is now possible to provide the index with synonym groups (.e.g boy, child, kid), and have it automatically index synonymous terms so that searching for one will return documents containing another.
See http://redisearch.io/Synonyms/ for more details and examples.
On this page