Dears
As shown, if the field is set to a number of type String, how can I query the data according to the condition?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @ChaoXiong ,
You can try using groovy script which can read the value from String property and save in long property. This will help you manipulate the content and query the field with numeric operations.
Thanks,
Nikita Garg
If the Field is String Type, you cannot expect numeral comparison as an output for logical operators. In the end, it is being compared as a String and not a numeral.
I would suggest changing the Data Type of this "number" property to Long instead of String.
Thanks @krati_garg
Because this is an example, there is already a lot of data in the actual project that is of String type, so I hope that there are related methods to query instead of modifying its type.
Hi @ChaoXiong ,
You can try using groovy script which can read the value from String property and save in long property. This will help you manipulate the content and query the field with numeric operations.
Thanks,
Nikita Garg
Hi @ChaoXiong
1. Use SQL2 Query and Cast statement to convert datatypes. How to use AEM JCR SQL2 query strings to query for nodes in Java Content Repository - Sourced Code
2. If property storing number with minimal range e.g., maximum number is 13 then use OR operator for 13 times in query builder query (Ugly solution)
FYI: If you want to change the data type - How to Change Data Type in AEM or Data Typecast using @TypeHint (argildx.us)
Hope this helps.
Thanks,
Chandra