I wanted to know if its possible to perform a full text search in AEM GraphQL API within content fragments?
For example I have a content fragment model which have 3 fields:
1. title
2. Body
3. date
I want to get all the content fragment where title contains `abc` and body contains `def`. I saw queryBuilder API and assets API. Assets API doesn't seem to support Searching and queryBuilder API does have limitations when querying nested content fragments. To give you an example:
I have a content fragment model User like this:
name: TextField
age: Number
address: Address (Another Content Fragment Model)
And here's how Adress looks like:
pinCode: Number
Street1: TextField
Street2: TextField
City: TextField
Country: TextField
When I query for `User` using queryBuilder API, I don't get complete `Address` fields instead I only get reference of `Address`. However when I query the same using GQL, I get all the fields and that's why I need the search functionality to happen in GQL. Is it possible as of AEM 6.5?
Solved! Go to Solution.
Views
Replies
Total Likes
Yes you can do "Contains" query in GQL, Please check this example out in this page.
query {
cityList(filter: {
name: {
_expressions: [
{
value: "SAN"
_operator: CONTAINS
_ignoreCase: true
}
]
}
}) {
items {
name
population
country
}
}
}
Sample Results
{
"data": {
"cityList": {
"items": [
{
"name": "San Francisco",
"population": 883306,
"country": "USA"
},
{
"name": "San Jose",
"population": 1026350,
"country": "USA"
}
]
}
}
}
Yes you can do "Contains" query in GQL, Please check this example out in this page.
query {
cityList(filter: {
name: {
_expressions: [
{
value: "SAN"
_operator: CONTAINS
_ignoreCase: true
}
]
}
}) {
items {
name
population
country
}
}
}
Sample Results
{
"data": {
"cityList": {
"items": [
{
"name": "San Francisco",
"population": 883306,
"country": "USA"
},
{
"name": "San Jose",
"population": 1026350,
"country": "USA"
}
]
}
}
}