Skip to content

Commit

Permalink
Support RediSearch DIALECT 5
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 committed May 5, 2024
1 parent 0691b57 commit a1163b9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/test/java/redis/clients/jedis/modules/search/SearchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,9 @@ public void testQueryParams() {

Query query = new Query("@numval:[$min $max]").addParam("min", 1).addParam("max", 2).dialect(2);
assertEquals(2, client.ftSearch(index, query).getTotalResults());

query = new Query("@numval:[$eq]").addParam("eq", 2).dialect(5);
assertEquals(1, client.ftSearch(index, query).getTotalResults());
}

@Test
Expand Down Expand Up @@ -532,6 +535,14 @@ public void testJsonWithAlias() {
res = client.ftSearch(index, new Query("@num:[0 10]"));
assertEquals(1, res.getTotalResults());
assertEquals("king:2", res.getDocuments().get(0).getId());

res = client.ftSearch(index, new Query("@num:[42 42]"));
assertEquals(1, res.getTotalResults());
assertEquals("king:1", res.getDocuments().get(0).getId());

res = client.ftSearch(index, new Query("@num:[42]").dialect(5));
assertEquals(1, res.getTotalResults());
assertEquals("king:1", res.getDocuments().get(0).getId());
}

@Test
Expand Down Expand Up @@ -773,6 +784,7 @@ public void getTagField() {
assertEquals(1, client.ftSearch(index, new Query("@category:{yellow}")).getTotalResults());
assertEquals(0, client.ftSearch(index, new Query("@category:{purple}")).getTotalResults());
assertEquals(1, client.ftSearch(index, new Query("@category:{orange\\;purple}")).getTotalResults());
assertEquals(1, client.ftSearch(index, new Query("@category:{orange;purple}").dialect(5)).getTotalResults());
assertEquals(4, client.ftSearch(index, new Query("hello")).getTotalResults());

assertEquals(new HashSet<>(Arrays.asList("red", "blue", "green", "yellow", "orange;purple")),
Expand Down Expand Up @@ -814,6 +826,7 @@ public void testGetTagFieldWithNonDefaultSeparator() {
assertEquals(1, client.ftSearch(index, new Query("hello @category:{yellow}")).getTotalResults());
assertEquals(0, client.ftSearch(index, new Query("@category:{purple}")).getTotalResults());
assertEquals(1, client.ftSearch(index, new Query("@category:{orange\\,purple}")).getTotalResults());
assertEquals(1, client.ftSearch(index, new Query("@category:{orange,purple}").dialect(5)).getTotalResults());
assertEquals(4, client.ftSearch(index, new Query("hello")).getTotalResults());

assertEquals(new HashSet<>(Arrays.asList("red", "blue", "green", "yellow", "orange,purple")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,9 @@ public void testQueryParams() {
assertEquals(2, client.ftSearch(index, "@numval:[$min $max]",
FTSearchParams.searchParams().params(paramValues)
.dialect(2)).getTotalResults());

assertEquals(1, client.ftSearch(index, "@numval:[$eq]",
FTSearchParams.searchParams().addParam("eq", 2).dialect(5)).getTotalResults());
}

@Test
Expand Down Expand Up @@ -574,6 +577,14 @@ public void testJsonWithAlias() {
res = client.ftSearch(index, "@num:[0 10]");
assertEquals(1, res.getTotalResults());
assertEquals("king:2", res.getDocuments().get(0).getId());

res = client.ftSearch(index, "@num:[42 42]", FTSearchParams.searchParams());
assertEquals(1, res.getTotalResults());
assertEquals("king:1", res.getDocuments().get(0).getId());

res = client.ftSearch(index, "@num:[42]", FTSearchParams.searchParams().dialect(5));
assertEquals(1, res.getTotalResults());
assertEquals("king:1", res.getDocuments().get(0).getId());
}

@Test
Expand Down Expand Up @@ -777,6 +788,8 @@ public void getTagField() {
assertEquals(1, client.ftSearch(index, "@category:{yellow}").getTotalResults());
assertEquals(0, client.ftSearch(index, "@category:{purple}").getTotalResults());
assertEquals(1, client.ftSearch(index, "@category:{orange\\;purple}").getTotalResults());
assertEquals(1, client.ftSearch(index, "@category:{orange;purple}",
FTSearchParams.searchParams().dialect(5)).getTotalResults());
assertEquals(4, client.ftSearch(index, "hello").getTotalResults());

assertEquals(new HashSet<>(Arrays.asList("red", "blue", "green", "yellow", "orange;purple")),
Expand Down Expand Up @@ -816,6 +829,8 @@ public void testGetTagFieldWithNonDefaultSeparator() {
assertEquals(1, client.ftSearch(index, "hello @category:{yellow}").getTotalResults());
assertEquals(0, client.ftSearch(index, "@category:{purple}").getTotalResults());
assertEquals(1, client.ftSearch(index, "@category:{orange\\,purple}").getTotalResults());
assertEquals(1, client.ftSearch(index, "@category:{orange\\,purple}",
FTSearchParams.searchParams().dialect(5)).getTotalResults());
assertEquals(4, client.ftSearch(index, "hello").getTotalResults());

assertEquals(new HashSet<>(Arrays.asList("red", "blue", "green", "yellow", "orange,purple")),
Expand Down

0 comments on commit a1163b9

Please sign in to comment.