Skip to content

Commit c6c4061

Browse files
author
Julien Ruaux
committed
test: Added test for AS attribute in RediSearch fields
1 parent d10cac2 commit c6c4061

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

subprojects/trino-redisearch/src/test/java/com/redis/trino/TestRediSearchConnectorSmokeTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
import org.testng.annotations.Test;
1717

1818
import com.google.common.base.Throwables;
19+
import com.redis.lettucemod.api.sync.RedisModulesCommands;
20+
import com.redis.lettucemod.search.CreateOptions;
21+
import com.redis.lettucemod.search.CreateOptions.DataType;
22+
import com.redis.lettucemod.search.Field;
1923
import com.redis.lettucemod.test.Beers;
2024

2125
import io.airlift.log.Logger;
@@ -109,6 +113,17 @@ public void testNonIndexedFields() throws IOException {
109113
getQueryRunner().execute("select id, last_mod from beers");
110114
}
111115

116+
@SuppressWarnings("unchecked")
117+
@Test
118+
public void testJsonSearch() throws IOException {
119+
RedisModulesCommands<String, String> sync = redisearch.getTestContext().getConnection().sync();
120+
sync.ftCreate("jsontest", CreateOptions.<String, String>builder().on(DataType.JSON).build(),
121+
Field.tag("$.id").as("id").build(), Field.text("$.message").as("message").build());
122+
sync.jsonSet("doc:1", "$", "{\"id\": \"1\", \"message\": \"this is a test\"}");
123+
sync.jsonSet("doc:2", "$", "{\"id\": \"2\", \"message\": \"this is another test\"}");
124+
getQueryRunner().execute("select id, message from jsontest");
125+
}
126+
112127
@Test
113128
public void testHaving() {
114129
throw new SkipException("Not supported by RediSearch connector");

0 commit comments

Comments
 (0)