RQL inside index definition #18354
Replies: 2 comments 4 replies
-
No, there is no possibility to do that. Only pure JS can be used there, what are you trying to do? |
Beta Was this translation helpful? Give feedback.
-
@ppekrol I'm trying to create a predefined filter on a specific collection, labels, ordered and limited by a parameters set by a user in my app. {
"displayName": "Home",
"labels": [],
"origin": null,
"slug": "/",
"createdAt": "2024-04-08T09:22:59.9620000Z",
"createdBy": "ffcb6a79-f1f3-4e21-b332-2713f31eeb81",
"publishedDate": "2024-04-08T09:43:58.4782990Z",
"deleted": false,
"heading": "A simple blog built with Astro, Tailwind CSS and Strife",
"posts": {
"take": 6,
"query": "from Posts as c where c.deleted != true AND c.labels in ('4a66f653-be65-4be6-b8be-23f3e911bfe0') order by c.publishedDate desc limit 6",
"collection": "Posts"
},
"@metadata": {
"@collection": "Landings",
"Raven-Clr-Type": "null"
}
} This works but I need to create multiple queries to get the // Get the home page content
const session = store.openSession();
const home = await session
.query({ indexName: 'Content/ByUrl' })
.whereEquals('url', Astro.url.pathname)
.firstOrNull();
// Get selected posts
const sortedPosts = await session.advanced.rawQuery(home.posts.query).all(); Also, this approach is not that flexible so I would rather see a different solution. Maybe create an index that is updated when the landing is changed or a new post is added, deleted or edited. In the case of creating an index, is is possible to index posts based on if a label exist and limit the indexing to a number, based on a specfic sort order? Like this query Maybe you have another solution in mind after reading this? |
Beta Was this translation helpful? Give feedback.
-
Is it possible to execute a RQL query inside an index definition like this?
Beta Was this translation helpful? Give feedback.
All reactions