You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add lexicographic string comparison support for Redis OM Spring (#526)
Implements lexicographic string comparison operations (>, <, >=, <=, between) for string fields
in Redis OM Spring. This feature enables efficient range queries on string data using Redis
sorted sets with ZRANGEBYLEX commands.
Key changes:
- Add lexicographic parameter to @indexed and @searchable annotations
- Implement sorted set indexing for fields marked with lexicographic=true
- Add gt(), lt(), and between() methods to TextTagField and TextField metamodel classes
- Support repository query methods like findByFieldGreaterThan for lexicographic fields
- Integrate lexicographic predicates with EntityStream API
- Create LexicographicQueryExecutor to handle repository method queries
- Implement marker/implementation predicate pattern for clean separation of concerns
Usage:
```java
@indexed(lexicographic = true)
private String comId;
// Repository method
List<Entity> findByComIdGreaterThan(String value);
// EntityStream API
entityStream.of(Entity.class)
.filter(Entity$.COM_ID.gt("100000"))
.collect(Collectors.toList());
```
NOTE: Lexicographic comparisons use Redis sorted sets for efficient range queries. They're ideal for ID ranges, SKU comparisons, version strings, and alphabetical filtering.
Copy file name to clipboardExpand all lines: docs/content/modules/ROOT/pages/index-annotations.adoc
+67Lines changed: 67 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,42 @@ public class Company {
37
37
}
38
38
----
39
39
40
+
==== Configuration Options:
41
+
42
+
* `sortable` - Whether the field can be used for sorting (default: false)
43
+
* `fieldName` - Custom field name in the index
44
+
* `alias` - Field alias for queries
45
+
* `indexMissing` - Index missing/null values (default: false)
46
+
* `indexEmpty` - Index empty string values (default: false)
47
+
* `lexicographic` - Enable lexicographic string comparisons for TAG fields (default: false)
48
+
49
+
==== Lexicographic String Comparisons
50
+
51
+
The `lexicographic` parameter enables string range queries (>, <, >=, <=, between) on TAG-indexed string fields by creating an additional Redis sorted set index:
NOTE: When using `lexicographic = true` on `@Searchable` fields, Redis OM Spring creates both a full-text index and a sorted set for range queries. This allows you to use both text search methods (like `findByTitleContaining`) and range queries (like `findByTitleGreaterThan`) on the same field.
Copy file name to clipboardExpand all lines: docs/content/modules/ROOT/pages/quickstart.adoc
+251Lines changed: 251 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -961,6 +961,257 @@ It is important to understand that as opposed to a regular Java stream, most ope
961
961
be executed server-side. On the query above the query is executed during and only during the terminal `collect` operation. At that point you
962
962
will have a `List<Company>` objects now loaded in memory.
963
963
964
+
== Step 21: Lexicographic String Comparisons
965
+
966
+
Redis OM Spring supports lexicographic (alphabetical) string comparisons for range queries on string fields. This is useful for finding entities within ID ranges, SKU comparisons, or alphabetical filtering.
967
+
968
+
Let's add a Product entity to demonstrate this feature:
@Indexed(lexicographic = true) // Version strings can be compared
1003
+
private String version;
1004
+
}
1005
+
----
1006
+
1007
+
Notice the `lexicographic = true` parameter on the `@Indexed` annotation. This tells Redis OM Spring to create an additional sorted set index for string range queries.
0 commit comments