cpsdb=# SELECT * FROM FRAGMENT WHERE anchor_id = 4 and attributes->>'lang' like '%en%';
Expandcode
title
Json ResponseClick here to expand..
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%';
Expandcode
title
Json Response Click here to expand
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';
Expandcode
title
Json ResponseClick here to expand
collapse
true
{
"lang":"en",
"price":699,
"title":"TheGoldenCompass",
"authors":[
"PhilipPullman"
],
"pub_year":1995
}
2.Using SIMILAR TO Regular Expression Keyword :
...
#
Query
Output
1
cpsdb=# SELECT * FROM FRAGMENT WHERE anchor_id = 3 and attributes->>'pub_year'similar to '%(94|95)%';
Expandcode
title
Json ResponseClick here to expand
{
"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