SearchinGhost - the new search plugin competitor

Hi everyone,

I started using Ghost more than 5 years ago but I only recently wanted to add in search capabilities. I found a lot of resources on this topic, espacially in this really great post: Search for Ghost. But I wasn’t fully happy with what I found… I wanted a solution easy to setup, javascript only (no jQuery), no server-side installation nor extra databases, using the Ghost API v3 and be able to run full-text search (not only title and tags).

So I started working on a dedicated search plugin before I realized that might interest Ghost community. Started two weeks ago, this project finally turned into an open source library: SearchinGhost.

SeachinGhost: A pure javascript, lightweight & in-browser full-text search plugin for Ghost (blog)

In its core, it rely on the Ghost Content API to fetch the data and the FlexSearch library to search through it. I found out that FlexSearch offered the best search result (in my opinion) compared to the others I tested (Lunr.js, minisearch, fuse.js).

If you are curious, here is the project repository: GitHub - gmfmi/searchinGhost: A pure javascript, lightweight & in-browser full-text search plugin for Ghost (blog). I am still looking for code/project reviews. Any idea or recommendation would be more than welcome, even documentation checks are useful! The current version (v0.5.0) can be considered as “release candidate” and I am confident enough to say it is production-ready. I am just waiting for documentation fix/improvement before publishing the v1.0.0. If you like to code, also feel free to contribute :)

If you are more a “show me the result, please!” person, here is the project demo (SearchinGhost | example) and here is the version set into my personnal blog (https://www.backtopack.fr/ - in french).

Also, I really wanted to thanks the GhostHunter and Ghost-search projects! They helped me to stay on the right path at the very beginning and keep everything clean.

Note: because of the COVID situation, I am still locked at home and I started a side project to bring a search bar to any Ghost theme with a “one-click”/no code solution. The idea is to be very (very) easy by being able to install it only from the Ghost admin adding one script from a CDN. Let me know if anyone is interested!

16 Likes

Hello

Thank you for your work, I tried each JavaScript solution and this one was the best for me. It works really great, it indexes everything including the tags, the live search is really good and I like what you did to limit the use if the network. :+1:

I have one question though : how does the indexing of new content work exactly ? Does it happen only when the cache is purged ? Right after adding some content to my Ghost site, it was not available in the results.

Here’s the configuration I’m using right now : London/custom-search.hbs at master · nicolinuxfr/London · GitHub

Again, thanks for your work !

Hi @nicolas, I am really happy to see that is can help someone, thank you for the kind reply!

Sorry for that, the internal work will be explained in the “internals” section of the README. You can control the indexing of new content using the “cacheMaxAge” options. By default, a check to find new posts is performed only after 1h delay. When something new is found, we wipe all the existing data and fetch everything fresh.

If you want to be sure your users are always up to date, you can set the “cacheMaxAge” to ‘0’ or ‘60’ seconds but you will receive a lot more requests…

OK, it makes sense, thanks for the explanation. I think I will reduce the cacheMaxAge for now.

Just downloaded it and installed it into the theme - works really well and is blazing fast as promised. I have tried Ghost finder but the search for this is faster. Thanks for making this! Will try lowering the cacheMaxAge value as well to see if this significantly slows the search.

Hi @chenningg,

Great, thank you for the feed back!

Just for you to know, there is absolutely NO link between the cacheMaxAge and the speed of searches. Everything is done in the background so there is no impact for the user experience.

When you are debugging, you can set the cacheMaxAge to low values (even 0 is OK) but I do not find any reason to do it in production. Except if you publish new articles every 30min or 40min, I personally think the default value of 1 hour is a good balance.

I understand. (: I mean having to reload the cached index every time to see if the generation of the index each time affects the user experience of the search or my website. If not, then it’s ok to have a lower cacheMaxAge. I agree that 1 hour is a good balance, just doing some testing to see if it makes a difference or not. Again, great search plugin!

I’m not understand how to install this in to Casper theme. Could you please send me a Casper theme with including this search? I’m new to ghost and I am not good at all. Please help me.

Sadly, yet, there is no way to easily “one-click” install it on the Casper theme.

SearchinGhost is like ghost-search or ghosthunter, it expects an already existing search HTML layout to work. Basically, it processes the user input coming from a search bar into an HTML result injected in the DOM.

For now, I think the best way to set it up is still to look at the official SearchinGhost example website and try to hunderstand how it works: SearchinGhost | example. I think it is small enough to port the logic to your own blog.

If your Ghost theme is already stored on a Github project, maybe you could give me a read-only access so I can make a pull request?

1 Like

I’ll store it and let you know. I’d like to have it like this ([https://www.backtopack.fr/])

Hey guys, @gmfmi helped me to put his searchinghost to my theme. He is very helpful and thank you @gmfmi :heart:

Hi everyone, while helping @thimiraonline with its theme I though it would be much more interesting to do something reusable and not only for this dedicated project.

So I came up with a new concept: Make search engine so easy that anyone can install it without any line of code nor theme update. I came up with Ghost Easybar.

https://github.com/gmfmi/ghost-easybar

The idea is to wrap together a Ghost search library (searchinghost, ghost-search or ghosthunter) with pre-made modal/pop up search layouts.

For now, the projet is still in an early stage but it works! I hope a proper documentation will be ready in a week :crossed_fingers:

If you know UI/UX designers that would be interested in sharing search box design, that would be a great help :grinning:. Currently, there is only 2 templates but I am idealy looking for 4 or 5.

4 Likes

Hi, @gmfmi Thank you for helping me. This is an suggestion to you. When I’m searching, images are loading in full resolution even it is resized by the url. I have used cloudinary to use resize images.

Thank you for the hint but I am not a huge fan of external services (even if Cloudinary is really great). I have a lot much easier solution. Starting with the v3, Ghost pre-process all the images with different sizes. I just use the best size for my use case (the one with 600px of width). That’s what I set up on backtopack.fr.

In the SearchinGhost configuration, simply add this line to the customProcessing field:

if (post.feature_image) post.feature_image = post.feature_image.replace('/images/', '/images/size/w600/');

And that’s it :grinning:. If you need to load them even quicker, replace w600 by w300.

2 Likes

Now I got that, when I typed a category name it loads every posts that owns to the related category. This is insane. :heart_eyes: Are there any other templated for search loading.

Really cool idea ! :+1:

1 Like

Hey @gmfmi,

Just checked out your plugin, I think it’s what I’m looking for.

I’m wondering if it can be integrated into a custom page and then queried by URL?

Kinda like how basecamp does it here: Signal v. Noise - Strong opinions and shared thoughts on design, business, and tech. By the makers (and friends) of Basecamp. Since 1999.

Hi @shavin47,

I just looked at signalvnoise.com and yeah, if you want to have the exact same behaviour, it is totally possible. You can integrate it into a custom page and display the results in the same page OR display the result into a dedicated page.

If you think you will need help to do it, send me a private message and I will explain your how to do it easily :wink:

1 Like

[MAJOR RELEASE]

To any SearchinGhost user, the current version is v1.3.1.

:warning: Important: since the v1.3.0, the library size has been reduced by 50%! So now, the user downloaded size is only 10 kB.

You might want to take some time to upgrade to the latest version :grinning:

1 Like

How colud I get upgraded?