From 555a2a4e8dc337b85075e6d8a351b6a73428bc91 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Thu, 13 Jun 2024 16:55:32 +0100 Subject: [PATCH] Improved search index request order no issue - we weren't adding an `order` param to our posts/pages requests used to populate the search index which meant the default Admin API ordering was applied which isn't optimal for this use-case - switched to ordering by `updated_at` to use a simple order that has an optimised index in the database --- ghost/admin/app/services/search-provider-beta.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ghost/admin/app/services/search-provider-beta.js b/ghost/admin/app/services/search-provider-beta.js index ef4cbdfbc6..d286f1250a 100644 --- a/ghost/admin/app/services/search-provider-beta.js +++ b/ghost/admin/app/services/search-provider-beta.js @@ -29,6 +29,7 @@ export const SEARCHABLES = [ name: 'Posts', model: 'post', fields: ['id', 'url', 'title', 'excerpt', 'status', 'published_at', 'visibility'], + order: 'updated_at desc', // ensure we use a simple rather than default order for faster response pathField: 'id', titleField: 'title', index: ['title', 'excerpt'] @@ -37,6 +38,7 @@ export const SEARCHABLES = [ name: 'Pages', model: 'page', fields: ['id', 'url', 'title', 'excerpt', 'status', 'published_at', 'visibility'], + order: 'updated_at desc', // ensure we use a simple rather than default order for faster response pathField: 'id', titleField: 'title', index: ['title', 'excerpt'] @@ -118,7 +120,7 @@ export default class SearchProviderService extends Service { async #loadSearchable(searchable) { const url = `${this.store.adapterFor(searchable.model).urlForQuery({}, searchable.model)}/`; - const query = {fields: searchable.fields, limit: 10000}; + const query = {fields: searchable.fields, limit: 10000, order: searchable.order}; try { const response = await this.ajax.request(url, {data: query});