...
Native query for Contains Operator using Like Keyword :
# Issue
Notes
Decisions 1 cpsdb=# SELECT * FROM FRAGMENT WHERE anchor_id = 4 and attributes->>'lang' ilike '%En%';
Query Response :
Code Blocktitle Json Response collapse true
{
"lang": "en",
"price": 699,
"title": "The Golden Compass",
"authors": [
"Philip Pullman"
],
"pub_year":1995
}
{
"lang": "English",
"price": 895,
"title": "Feersum Endjinn",
"authors": [
"Iain M. Banks"
],
"pub_year":1994
}
27 Mar 2023 As per discussion , with Toine Siebelink Prefers Contains Xpath is case sensitive , So ilike keyword would be suitable to implement the contains query which support case sensitive attribute values.
Need to discuss with stakeholders.
#
Json Data
Output
1 Below is the sample data ,
Here are ways to use contains keyword :
Code Blocktitle Json data collapse true
{
"test:bookstore":{
"bookstore-name": "Chapters",
"categories": [
{
"code": "01",
"name": "SciFi",
"books": [
{
"authors": [
"Iain M. Banks"
],
"lang": "english",
"price": "895",
"pub_year": "1994",
"title": "Feersum Endjinn"
}
]
},
{
"name": "kids",
"code": "02",
"books": [
{
"authors": [
"Philip Pullman"
],
"lang": "Science",
"price": "699",
"pub_year": "1995",
"title": "The Golden Compass"
}
]
}
]
}
}
<cps-path>(contains'[@leafname,'<string-value>']') Examples //books[contains(@lang,'en') //books[contains(@pub_year,'99')
Code Blocktitle Json Response collapse true
{
"lang": "en",
"price": 895,
"title": "Feersum Endjinn",
"authors": [
"Iain M. Banks"
],
"pub_year":1994
}
{
"lang": "en",
"price": 699,
"title": "The Golden Compass",
"authors": [
"Philip Pullman"
],
"pub_year":1995
}
...