Search code examples
jsonorientdborientdb-2.1

OrientDB use LIKE in an encapsulated field


I have an OrientDB table named CalculationFunctionGroup, in which I have a field named functions.

This field has JSON content like this:

[{"@type":"d","@version":0,"@class":"CalculationFunction","name":"AR_0015_0280","code":"//AR_0015_0280 OTTIMIZZATA / FORMATTATA\nvar worka01 = anagPay(\"AR_0015_0280\", -1);\nreturn worka01;","language":"Javascript"}]

I want to extract rows satisfying a LIKE condition on the code element of the JSON.

I've tried this query:

SELECT FROM CalculationFunctionGroup
WHERE functions.code LIKE '%OTTIMIZZATA%'

But the number of extracted rows is ZERO!


Solution

  • Try this:

    select expand(distinct(rid))
    from (select @rid,functions.code
          from CalculationFunctionGroup unwind functions)
    where functions like "%OTTIMIZZATA%"