A better search for Ghost - and it's not Algolia (and open source!)

I’m running Ghost via default official supported method (no Docker).

localhost is 127.0.0.1 and I can reach the Ghost API from both urls, including https as well.

ghost-typesense CLI is installed via npm no Docker.

It’s very strange to me, I’m open to experiment and any suggestion that could fix this issue.

I’m trying to configure typesense in Ghost 6.0.3

Everything was going well until until I get this error:

error: ‘Request failed with HTTP code 400 | Server said: Field tags must be an array of string.’

When run ghost-typesense sync --config ghost-typesense.config.json

Any idea?

Thanks

Thank you for reporting!

I just fixed that bug. You can run npm install -g @magicpages/ghost-typesense-cli to update the CLI. After that, ghost-typesense sync --config ghost-typesense.config.json should work again.

1 Like

Thanks Jannis. Now I get no error. But when truing to search the blog, I get the message: No results found for your search

What am I missing?

Also, need to keep the “version”: “v5.0”

If I change to v6.0 get this error:

Failed to initialize collection: [
{
“received”: “v6.0”,
“code”: “invalid_literal”,
“expected”: “v5.0”,
“path”: [
“ghost”,
“version”
],
“message”: “Invalid literal value, expected “v5.0””
}
]

Can you share an URL to your site? Feel free to send me a DM.

Yes, the version should stay at v5.0 for now. ts-ghost, the Typescript library under the hood, has not been updated for Ghost 6 yet, but everything should work as expected.

I’m in a test environment with no public access, but I’ll try to configure one and let you know.

Thanks

In that case, I’d check if Typesense has all posts indexed and if the configuration in the code injection is working properly (e.g. what’s happening in the network requests to the Typesense server)

I’m new to Typesense and Ghost, but as far as I noticed, when I ran ghost-typesense sync --config ghost-typesense.config.json , I saw a list of documents in the blog.

Typesense is on the same server as Ghost. The health check returns ok:

curl http://localhost:8108/health
{“ok”:true}

I sent you a DM

Thanks

Another thing I notice is, no matter I choose theme: ‘light’, ‘dark’, or ‘system’

Nothing changes

Hi Jannis, I’ve set this up on my Ghost Pro website, it’s great, thanks! I did have a request from some users though: they’d like the search results to show what date each article/post is from, and the ability to make search results ordered by most recent first. Is that possible?

The search is getting an overhaul this year:

The dates is definitely something I can keep in mind for that (though, no concrete release date, as it’s dependent on a few other Magic Pages internal requirements).

The search result ordering is something you can already set in your search config:

window.__MP_SEARCH_CONFIG__ = {
    // ...existing config                                                                                   
    typesenseSearchParams: {
        sort_by: 'published_at:desc'                                                                              
    }                                                            
};

This will sort results by newest first instead of the default relevance-based ordering. I’ve just updated the README to properly reflect that:

4 Likes

Thanks, I’ve made that change now – works great.

1 Like

It’s been over a year since I first released the ghost-typesense package. Today I’ve release v2.0.0, which includes a ton of improvements, all based on the feedback of hundreds of publishers using the search on Magic Pages.

(The new features are not yet available on Magic Pages, since they still need some backend implementations, so if you’re a Magic Pages customer, this is a teaser of what’s to come in the next 1-2 weeks :wink: )

Here’s an overview of what’s new:

Selectable UI layouts (uiStyle)

  • modal (default): now with rich result rows; supports list / grid templates.

  • palette: command-style palette with grouped Posts / Tags / Authors and recent searches.

  • discovery: two-pane explorer with a live preview pane and a facet rail.

Here are a couple of screenshots of the improved and new UI layouts:

Search

  • Semantic (vector-based) search with keyword-favoring defaults (meaning, direct keyword-hits will still be preferred over pure semantic results based on the underlying vectors).
  • Curated + dynamic suggestions: you can now add dynamic search suggestions from a backend of your choice. The search accepts an endpoint that provides these. Great, if you build something around the search – like Magic Pages.
  • Author + Tag search: authors and tags are now fully searchable (tags were searchable already)
  • Members-only content indexing: member-only content will be redacted (so no content is leaked), but discoverable. Great as lead magnets to your memberships.
  • Opt-in analytics: the search can emit events on search/click/zero-results, sent to your own endpoint. Again, great if you build something around the search, like Magic Pages

Apart from these, there were a few quality-of-life improvements and bug fixes, which will make it easier to iterate of the tooling in the future.

Upgrades from the existing v1.12.0 should be pretty straightforward, but a couple of features require re-indexing of the Typesense collection. Details see here: Release v2.0.0 — Selectable layouts, semantic search, facets & more · magicpages/ghost-typesense · GitHub

Looking forward to all of your feedback!

3 Likes

This is such an underrated feature!

2 Likes