|
4 | 4 | :project-name: redis-sql |
5 | 5 | :project-group: com.redis |
6 | 6 | :project-version: 0.2.5 |
| 7 | +:project-url: https://github.com/{project-owner}/{project-name} |
7 | 8 | :artifact-id: trino-redisearch |
8 | | -:codecov-token: CQFF495IPH |
| 9 | +:trino-dir: /usr/lib/trino |
| 10 | +:trino-datadir: /var/trino |
| 11 | +:trino-version: 395 |
9 | 12 |
|
10 | | -image:https://github.com/{project-owner}/{project-name}/actions/workflows/early-access.yml/badge.svg["Build Status", link="https://github.com/{project-owner}/{project-name}/actions/workflows/early-access.yml"] |
| 13 | +image:{project-url}/actions/workflows/early-access.yml/badge.svg["Build Status", link="{project-url}/actions/workflows/early-access.yml"] |
11 | 14 | image:https://codecov.io/gh/{project-owner}/{project-name}/branch/master/graph/badge.svg?token={codecov-token}["Coverage", link="https://codecov.io/gh/{project-owner}/{project-name}"] |
12 | 15 |
|
13 | | -Redis SQL is a SQL interface to https://oss.redislabs.com/redisearch/[RediSearch] implemented as a https://trino.io[Trino] connector. |
14 | | -It allows the use of RediSearch indexes as tables in Trino. |
| 16 | +Redis SQL is a https://trino.io[Trino] connector which allows access to RediSearch data from Trino. |
| 17 | +This document describes how to set up the RediSearch Connector to run SQL queries against RediSearch. |
15 | 18 |
|
16 | | -== Requirements |
17 | | - |
18 | | -To connect to RediSearch you need: |
19 | | - |
20 | | -. RediSearch 2.0 or higher |
21 | | -. Network access from the Trino coordinator and workers to RediSearch. |
| 19 | +NOTE: RediSearch 2.0 or later is required. |
22 | 20 |
|
23 | 21 | == Configuration |
24 | | - |
25 | | -To configure the RediSearch connector, create a catalog properties file `etc/catalog/redisearch.properties` with the following contents (replace properties as appropriate): |
| 22 | +To configure the RediSearch connector, create a catalog properties file `etc/catalog/redisearch.properties` with the following contents, replacing the properties as appropriate: |
26 | 23 |
|
27 | 24 | [source,properties] |
28 | 25 | ---- |
29 | 26 | connector.name=redisearch |
30 | | -redisearch.uri=redis://user:pass@host:6379 |
| 27 | +redisearch.uri=redis://localhost:6379 |
| 28 | +redisearch.default-schema-name=default |
31 | 29 | ---- |
32 | 30 |
|
33 | | -=== Configuration Properties |
| 31 | +[[properties]] |
| 32 | +=== Configuration properties |
34 | 33 |
|
35 | | -`redisearch.uri`:: A connection string containing the protocol, credential, and host info to connect to Redis. |
36 | | -+ |
37 | | -For example, the connection string may use the format `redis://<user>:<pass>@<host>:<port>`. |
38 | | -+ |
39 | | -See the https://github.com/lettuce-io/lettuce-core/wiki/Redis-URI-and-connection-details#uri-syntax[Redis URI syntax] for more information. |
40 | | -+ |
41 | | -This property is required and has no default. A Redis URI must be provided to connect to RediSearch. |
| 34 | +[cols="1,1,1"] |
| 35 | +|=== |
| 36 | +|Property name |Description |Default |
42 | 37 |
|
43 | | -`redisearch.username`:: Redis connection username. |
| 38 | +|`redisearch.uri` |
| 39 | +|A Redis connection string. https://github.com/lettuce-io/lettuce-core/wiki/Redis-URI-and-connection-details#uri-syntax[Redis URI syntax]. |
| 40 | +| |
44 | 41 |
|
45 | | -`redisearch.password`:: Redis connection password. |
| 42 | +|`redisearch.default-schema-name` |
| 43 | +|The schema that contains all tables defined without a qualifying schema name. |
| 44 | +|`default` |
46 | 45 |
|
47 | | -`redisearch.insecure`:: Allow insecure connections (e.g. invalid certificates) to Redis when using SSL. |
48 | | -+ |
49 | | -This property is optional and the default is `false`. |
| 46 | +|`redisearch.username` |
| 47 | +|Redis connection username. |
| 48 | +| |
50 | 49 |
|
51 | | -`redisearch.timeout`:: Redis command timeout in seconds. |
52 | | -+ |
53 | | -This property is optional and the default is `60`. |
| 50 | +|`redisearch.password` |
| 51 | +|Redis connection password. |
| 52 | +| |
54 | 53 |
|
55 | | -`redisearch.case-insensitive-name-matching`:: Match index names case insensitively. |
56 | | -+ |
57 | | -This property is optional and the default is `false`. |
| 54 | +|`redisearch.cluster` |
| 55 | +|Connect to a Redis Cluster. |
| 56 | +|`false` |
58 | 57 |
|
59 | | -`redisearch.default-limit`:: Max number of documents returned by FT.SEARCH and FT.AGGREGATE when no limit is present in the SQL query. |
60 | | -+ |
61 | | -This property is optional and the default is `10000`. |
| 58 | +|`redisearch.case-insensitive-names` |
| 59 | +|Match index names case insensitively. |
| 60 | +|`false` |
62 | 61 |
|
63 | | -`redisearch.cursor-count`:: Number of rows read during each https://redis.io/docs/stack/search/reference/aggregations/#cursor-api[aggregation cursor] fetch. |
64 | | -+ |
65 | | -This property is optional and if it is not specified the RediSearch default is used. |
| 62 | +|`redisearch.default-limit` |
| 63 | +|Max number of documents returned by FT.SEARCH and FT.AGGREGATE when no limit is present in the SQL query. |
| 64 | +|`10000` |
| 65 | + |
| 66 | +|`redisearch.cursor-count` |
| 67 | +|Number of rows read during each https://redis.io/docs/stack/search/reference/aggregations/#cursor-api[aggregation cursor] fetch. |
| 68 | +|`1000` |
| 69 | +|=== |
| 70 | + |
| 71 | +== TLS security |
| 72 | +The RediSearch connector provides additional security options to support Redis servers with TLS mode. |
| 73 | + |
| 74 | +The allowed configuration values are: |
| 75 | + |
| 76 | +[cols="1,1"] |
| 77 | +|=== |
| 78 | +|Property name |Description |
| 79 | + |
| 80 | +|`redisearch.insecure` |
| 81 | +|Allow insecure connections (e.g. invalid certificates) when using SSL. |
| 82 | + |
| 83 | +|`redisearch.cacert-path` |
| 84 | +|X.509 CA certificate file to verify with. |
| 85 | + |
| 86 | +|`redisearch.key-path` |
| 87 | +|PKCS#8 private key file to authenticate with (PEM format). |
| 88 | + |
| 89 | +|`redisearch.key-password` |
| 90 | +|Password of the private key file, or null if it's not password-protected. |
| 91 | + |
| 92 | +|`redisearch.cert-path` |
| 93 | +|X.509 certificate chain file to authenticate with (PEM format). |
| 94 | +|=== |
66 | 95 |
|
67 | 96 |
|
68 | 97 | == Docker Example |
@@ -102,68 +131,163 @@ docker exec -it trino trino --catalog redisearch --schema default |
102 | 131 | trino:default> select * from beers; |
103 | 132 | ---- |
104 | 133 |
|
| 134 | +== Tableau |
| 135 | + |
| 136 | +Follow these steps to connect Tableau: https://help.tableau.com/current/pro/desktop/en-us/examples_presto.htm |
| 137 | + |
105 | 138 | == Install and Run |
106 | 139 |
|
107 | | -=== Install Trino |
| 140 | +=== Trino |
| 141 | + |
| 142 | +Trino installation instructions are available here: https://trino.io/docs/current/installation.html |
108 | 143 |
|
109 | | -https://trino.io/docs/current/installation.html |
| 144 | +The following steps deploy a single-node Trino server on Ubuntu. |
110 | 145 |
|
111 | | -For macOS: `brew install trino` |
| 146 | +Trino requires a 64-bit of Java 17. |
| 147 | +It is recommended to https://www.azul.com/downloads/?package=jdk[Azul Zulu] as the JDK. |
| 148 | +[source,console] |
| 149 | +---- |
| 150 | +$ java -version |
| 151 | +openjdk version "17.0.4.1" 2022-08-12 LTS |
| 152 | +OpenJDK Runtime Environment Zulu17.36+17-CA (build 17.0.4.1+1-LTS) |
| 153 | +OpenJDK 64-Bit Server VM Zulu17.36+17-CA (build 17.0.4.1+1-LTS, mixed mode, sharing) |
| 154 | +---- |
112 | 155 |
|
113 | | -=== Install the connector |
| 156 | +Download the Trino server tarball and unpack it. |
| 157 | +[source,console,subs="verbatim,attributes"] |
| 158 | +---- |
| 159 | +wget https://repo1.maven.org/maven2/io/trino/trino-server/{trino-version}/trino-server-{trino-version}.tar.gz |
| 160 | +mkdir {trino-dir} |
| 161 | +tar xzvf trino-server-{trino-version}.tar.gz --directory {trino-dir} --strip-components 1 |
| 162 | +---- |
114 | 163 |
|
115 | | -1. Download latest https://github.com/redis-field-engineering/{project-name}/releases/latest[release]. |
| 164 | +Trino needs a data directory for storing logs, etc. |
| 165 | +It is recommended to create a data directory outside of the installation directory, which allows it to be easily preserved when upgrading Trino. |
| 166 | +[source,console,subs="verbatim,attributes"] |
| 167 | +---- |
| 168 | +mkdir -p {trino-datadir} |
| 169 | +---- |
116 | 170 |
|
117 | | -2. Unzip the release without any directory structure under `<trino>/plugin/redisearch`: |
118 | | -+ |
| 171 | +Create an `etc` directory inside the installation directory to hold configuration files. |
119 | 172 | [source,console,subs="verbatim,attributes"] |
120 | 173 | ---- |
121 | | -unzip -j trino-redisearch-{project-version}.zip -d /opt/trino/plugin/redisearch |
| 174 | +mkdir {trino-dir}/etc |
122 | 175 | ---- |
123 | 176 |
|
124 | | -3. Create a `redisearch.properties` file under `<trino>/etc/catalog` directory: |
125 | | -+ |
126 | | -.redisearch.properties |
| 177 | +Create a node properties file `etc/node.properties`. |
| 178 | + |
| 179 | +.{trino-dir}/etc/node.properties |
| 180 | +[source,properties,subs="verbatim,attributes"] |
| 181 | +---- |
| 182 | +node.environment=production |
| 183 | +node.id=ffffffff-ffff-ffff-ffff-ffffffffffff |
| 184 | +node.data-dir={trino-datadir} |
| 185 | +---- |
| 186 | + |
| 187 | +Create a JVM config file `etc/jvm.config`. |
| 188 | + |
| 189 | +.{trino-dir}/etc/jvm.config |
| 190 | +[source,properties] |
| 191 | +---- |
| 192 | +-server |
| 193 | +-Xmx16G |
| 194 | +-XX:InitialRAMPercentage=80 |
| 195 | +-XX:MaxRAMPercentage=80 |
| 196 | +-XX:G1HeapRegionSize=32M |
| 197 | +-XX:+ExplicitGCInvokesConcurrent |
| 198 | +-XX:+ExitOnOutOfMemoryError |
| 199 | +-XX:+HeapDumpOnOutOfMemoryError |
| 200 | +-XX:-OmitStackTraceInFastThrow |
| 201 | +-XX:ReservedCodeCacheSize=512M |
| 202 | +-XX:PerMethodRecompilationCutoff=10000 |
| 203 | +-XX:PerBytecodeRecompilationCutoff=10000 |
| 204 | +-Djdk.attach.allowAttachSelf=true |
| 205 | +-Djdk.nio.maxCachedBufferSize=2000000 |
| 206 | +-XX:+UnlockDiagnosticVMOptions |
| 207 | +-XX:+UseAESCTRIntrinsics |
| 208 | +---- |
| 209 | + |
| 210 | +Create a config properties file `etc/config.properties`. |
| 211 | +.{trino-dir}/etc/config.properties |
| 212 | +[source,properties] |
| 213 | +---- |
| 214 | +coordinator=true |
| 215 | +node-scheduler.include-coordinator=true |
| 216 | +http-server.http.port=8080 |
| 217 | +discovery.uri=http://localhost:8080 |
| 218 | +---- |
| 219 | + |
| 220 | +Create a log levels file `etc/log.properties`. |
| 221 | +.{trino-dir}/etc/log.properties |
| 222 | +[source,properties] |
| 223 | +---- |
| 224 | +io.trino=INFO |
| 225 | +---- |
| 226 | + |
| 227 | +=== Redis SQL |
| 228 | + |
| 229 | +Download latest {project-url}/releases/latest[release] and unzip without any directory structure under `<trino>/plugin/redisearch`. |
| 230 | + |
| 231 | +[source,console,subs="verbatim,attributes"] |
| 232 | +---- |
| 233 | +wget {project-url}/releases/download/v{trino-version}/{artifact-id}-{trino-version}.zip |
| 234 | +unzip -j {artifact-id}-{project-version}.zip -d {trino-dir}/plugin/redisearch |
| 235 | +---- |
| 236 | + |
| 237 | +Create a `redisearch.properties` file under `{trino-dir}/etc/catalog` directory: |
| 238 | + |
127 | 239 | [source,properties] |
128 | 240 | ---- |
129 | 241 | connector.name=redisearch |
130 | 242 | redisearch.uri=redis://localhost:6379 |
131 | 243 | ---- |
132 | 244 |
|
| 245 | +Change and/or add <<properties,properties>> as needed. |
| 246 | + |
133 | 247 | === Run |
134 | 248 |
|
135 | | -1. Start Trino server: |
136 | | -+ |
137 | | -[source,console] |
| 249 | +==== Trino Server |
| 250 | + |
| 251 | +Start the Trino server by running: |
| 252 | + |
| 253 | +[source,console,subs="verbatim,attributes"] |
138 | 254 | ---- |
139 | | -trino-server start |
| 255 | +{trino-dir}/bin/launcher run |
140 | 256 | ---- |
141 | 257 |
|
142 | | -2. Connect to Trino using the CLI: |
143 | | -+ |
144 | | -[source,console] |
| 258 | +==== Trino CLI |
| 259 | + |
| 260 | +Download https://repo1.maven.org/maven2/io/trino/trino-cli/{trino-version}/trino-cli-{trino-version}-executable.jar[trino-cli-{trino-version}-executable.jar], rename it to `trino`, make it executable with `chmod +x`, and run it to show the version of the CLI: |
| 261 | + |
| 262 | +[source,console,subs="verbatim,attributes"] |
145 | 263 | ---- |
146 | | -trino --catalog redisearch --schema default |
| 264 | +wget https://repo1.maven.org/maven2/io/trino/trino-cli/{trino-version}/trino-cli-{trino-version}-executable.jar |
| 265 | +mv trino-cli-{trino-version}-executable.jar trino |
| 266 | +chmod +x trino |
147 | 267 | ---- |
148 | 268 |
|
149 | | -3. Run a SQL query: |
150 | | -+ |
| 269 | +Connect to Trino using the CLI: |
| 270 | + |
151 | 271 | [source,console] |
152 | 272 | ---- |
153 | | -trino:default> select count(*) from myIdx; |
| 273 | +./trino --catalog redisearch --schema default |
154 | 274 | ---- |
155 | 275 |
|
156 | | -== Tableau |
| 276 | +Run a SQL query: |
157 | 277 |
|
158 | | -Follow these steps to connect Tableau: https://help.tableau.com/current/pro/desktop/en-us/examples_presto.htm |
| 278 | +[source,console] |
| 279 | +---- |
| 280 | +trino:default> select * from mySearchIndex; |
| 281 | +---- |
159 | 282 |
|
160 | 283 | == Build |
161 | 284 |
|
162 | | -Run these commands to build the Trino connector for RediSearch from source: |
| 285 | +Run these commands to build the Trino connector for RediSearch from source (requires Java 17+): |
163 | 286 |
|
164 | | -[source,console] |
| 287 | +[source,console,subs="verbatim,attributes"] |
165 | 288 | ---- |
166 | | -git clone https://github.com/redis-field-engineering/redis-sql.git |
167 | | -cd redis-sql |
| 289 | +git clone {project-url}.git |
| 290 | +cd {project-name} |
168 | 291 | ./gradlew clean build |
169 | 292 | ---- |
| 293 | + |
0 commit comments