cpsdb=# SELECT * FROM FRAGMENT WHERE anchor_id = 4 and attributes->>'lang' like '%en%';
expand
Code Block
title
Json Response
collapse
true
{
"lang":"en",
"price":699,
"title":"TheGoldenCompass",
"authors":[
"PhilipPullman"
],
"pub_year":1995
}
{
"lang":"english",
"price":895,
"title":"FeersumEndjinn",
"authors":[
"IainM.Banks"
],
"pub_year":1994
}
2
cpsdb=# SELECT * FROM FRAGMENT WHERE anchor_id = 4 and attributes->>'lang' ilike '%En%';
expand
Code Block
title
Json Response
collapse
true
{
"lang":"en",
"price":699,
"title":"TheGoldenCompass",
"authors":[
"PhilipPullman"
],
"pub_year":1995
}
{
"lang":"English",
"price":895,
"title":"FeersumEndjinn",
"authors":[
"IainM.Banks"
],
"pub_year":1994
}
As per discussion , with Toine Siebelink Contains Xpath is case sensitive , So ilike keyword would be suitable to implement the contains query which support case sensitive attribute values
3
cpsdb=# SELECT * FROM FRAGMENT WHERE anchor_id = 4 and attributes->>'lang' like 'en';
expand
Code Block
title
Json Response
collapse
true
{
"lang":"en",
"price":699,
"title":"TheGoldenCompass",
"authors":[
"PhilipPullman"
],
"pub_year":1995
}
2.Using SIMILAR TO Regular Expression Keyword :
...
|denotes alternation (either of two alternatives).
*denotes repetition of the previous item zero or more times.
+denotes repetition of the previous item one or more times.
?denotes repetition of the previous item zero or one time.
{m}denotes repetition of the previous item exactlymtimes.
{m,}denotes repetition of the previous itemmor more times.
{m,n}denotes repetition of the previous item at leastmand not more thanntimes.
Parentheses()can be used to group items into a single logical item.
A bracket expression[...]specifies a character class, just as in POSIX regular expressions.
#
Query
Output
1
cpsdb=# SELECT * FROM FRAGMENT WHERE anchor_id = 3 and attributes->>'pub_year'similar to '%(94|95)%';
expand
Code Block
title
Json Response
collapse
true
{
"lang":"en",
"price":699,
"title":"TheGoldenCompass",
"authors":[
"PhilipPullman"
],
"pub_year":1995
}
{
"lang":"english",
"price":895,
"title":"FeersumEndjinn",
"authors":[
"IainM.Banks"
],
"pub_year":1994
}
Performance wise : As we are not making much changes for query , the performance is similar to existing query will not effect much
Implementation of Contains Operator
1.Update antlr parser to recognize this pattern 2.Implement required (native) query 3.Add Integration tests for a.filter on string leaf-value b.filter on Integer leaf-value 4.Update documentation 5.demo to team
Limitations
1. contains condition is case sensitive. 2. Only leaves can be used, leaf-list are not supported. 3. Only string and integer values are supported, boolean and float values are not supported. 4. When empty value is passed with contains it returns all the nodes that has given leaf element.