Skip to content

Commit 4a4cdc9

Browse files
committed
docs: document @indexed(alias) support for uppercase JSON fields in Map values
Add documentation explaining how to use @indexed(alias) annotation on nested object fields within Map values to handle uppercase JSON field names while maintaining Java naming conventions. This documents the feature added in commit 5dc89b5.
1 parent 32073da commit 4a4cdc9

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

docs/content/modules/ROOT/pages/json-map-fields.adoc

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,66 @@ $.positions.*.description -> TAG field (positions_description)
289289

290290
This structure enables efficient queries across all map values, regardless of their keys.
291291

292+
=== Handling Uppercase JSON Fields in Complex Map Values
293+
294+
When working with external JSON data that uses uppercase field names, you can use the `@Indexed(alias)` annotation on nested object fields within Map values to maintain proper Java naming conventions while preserving the original JSON structure:
295+
296+
[source,java]
297+
----
298+
// Complex object with uppercase JSON fields
299+
@Data
300+
public class Position {
301+
@Indexed(alias = "CUSIP")
302+
@JsonProperty("CUSIP")
303+
private String cusip;
304+
305+
@Indexed(alias = "QUANTITY")
306+
@JsonProperty("QUANTITY")
307+
private Integer quantity;
308+
309+
@Indexed(alias = "PRICE")
310+
@JsonProperty("PRICE")
311+
private BigDecimal price;
312+
313+
@Indexed
314+
private String manager; // Standard field naming
315+
}
316+
317+
// Entity using the complex object in a Map
318+
@Document
319+
public class Account {
320+
@Id
321+
private String id;
322+
323+
@Indexed(alias = "ACCOUNTID")
324+
@JsonProperty("ACCOUNTID")
325+
private String accountId;
326+
327+
@Indexed(schemaFieldType = SchemaFieldType.NESTED)
328+
private Map<String, Position> positions;
329+
}
330+
331+
// Repository queries work with the alias
332+
public interface AccountRepository extends RedisDocumentRepository<Account, String> {
333+
// Queries the uppercase CUSIP field via alias
334+
List<Account> findByPositionsMapContainsCusip(String cusip);
335+
336+
// Queries the uppercase QUANTITY field via alias
337+
List<Account> findByPositionsMapContainsQuantityGreaterThan(Integer quantity);
338+
339+
// Queries the uppercase PRICE field via alias
340+
List<Account> findByPositionsMapContainsPriceLessThan(BigDecimal price);
341+
}
342+
----
343+
344+
This approach allows you to:
345+
* Maintain clean Java code with standard camelCase naming conventions
346+
* Work seamlessly with JSON data that uses uppercase field names
347+
* Query nested fields using their aliased names in repository methods
348+
* Preserve the original JSON structure for compatibility with external systems
349+
350+
NOTE: The `@Indexed(alias)` annotation must match the `@JsonProperty` value for proper indexing and querying to work.
351+
292352
== Advanced Examples
293353

294354
=== Working with Other Complex Value Types

0 commit comments

Comments
 (0)