Search made simple - SearchinGhostEASY

Hi @gmfmi
I installed SearchingHostEasy. Thank you!
If I managed to do it with zero knowledge of, or comfort with, coding means your instructions are super clear.
I would really like to remove the limit of posts found on a search - which I can see is doable, WHERE do I make the change?

1 Like

Used your plugin to our new opensource theme GitHub - Inoryum-Ltd/aesto: Free Ghost theme with membership support. Minimal content focused design with multi author supported.
Thanks for this super easy & robust plugin.

Cheers!

1 Like

Hi @stuart,

Happy to see it fits your needs :smiley:

To manage the number of displayed results, use the searchinghostOptions option:

new SearchinGhostEasy({
    contentApiKey: '<CONTENT_API_KEY>', // mandatory
    searchinghostOptions: {
        limit: 23
    }
});

Set the limit value with your own value. If you really want to display ALL posts found (which I do NOT recommand), set this value to 0. In most cases, you probably do not need to set a value greater than 100.

1 Like

Thanks for coming back to me.

Sorry if this a dumb question - but do I simply copy/paste that into the code injection?

No worries @stuart, there is no “dumb” question. If you are using the code injection option, at the end, you should get something that looks like this screenshot:

Feel free to send my a private message if you need more support :wink:

1 Like

As non i.t related person, i cant emphasizes enough how helpful and almost 80% percent of my prob is settled with ur search engine. Many user searching thru my stock r happy. I cant thank enough n really grateful that i came across u. Other seller can search not only by model also by specifications of the car. My D.I.Y page
https://kssotomobil.com/. Using ghost as my car inventory reference. Tq my hero. Keepup the good work

1 Like

Is this viable for high load instances? thousands of posts? etc.? How does performance fair on a Ghost install with 1000 posts?

Yes, it is, depending on what you want to achieve.

Let’s say, you want to be able to search post’s titles and tags and then display the results with an image. No issue at all, that is exactly what we setup on this website which as currently 646 posts. I think it can even scale up to more than 10000 posts without any issue or lags, keeping an instant result display feeling. We decided to go this way because, based on their content, more than 500 posts did not fit in browser cache.

So now, if you want to do a full text indexation of more than 1000 posts, it becomes a real challenge to make it work within a browser. There are 2 main limitations:

  1. Downloading such a large payload and indexing it at each page load (while being fast enough so nobody notice what is going on under the hood)
  2. Caching the result in the browser local storage to limit this network interaction. I tested it by iterating over 40 posts to recreate a 1000 posts payload and I reached the browser limitation.

Basically, I think indexing more than 1000 post in a full-text fashion should be done on the server side instead of the client browser. So you will probably fall back to a more traditional/heavy search solution such as Elasticsearch or you can embed SearchinGhost (or any JS search engine) in a node.js server to deal with request on the server side.

Let me know what you think about it and if you need a hand to do something.

1 Like

Hi @gmfmi,
Can I use my custom input and custom markup in your searching plugin? I want to use my custom markup.

Thanks

Hi @ENAMUL_HAQUE ,

If you want to use a completely custom theme/template, you should better use the original underlying library SearchinGhost. Basically, the “EASY” version (in this topic) is just one implementation of the library to make it super easy for “non I.T.” persons.

About SearchinGhost, only a little bit of configuration is required because the default values are generally a good fit but if you want to tweak everything, here is the official options documentation. You will probably need to update the inputId and template fields.

As a bonus, if you are using a JS framework (like Vue.js, react, etc), you can use SearchinGhost purely as a library without DOM interactions, see this documentation section.

I hope that is useful to you :slight_smile:

Thank you @gmfmi for your outstanding work. Just what I needed as a non-code person.
(Really like your blog btw.) :slight_smile:

1 Like

Thanks so much for releasing this @gmfmi . It works great. One question though, when an article is unpublished it still shows up on search. How do you increment the search feature to re-index the pages? I know some other searches use things like “v2”. I was wondering how it works with SearchinGhostEasy?

Hi @Beric, interesting question! Actually, I never though about this issue before.

Currently, to know if we need to re-index, I fetch the latest post by ‘updated_at’ fields. If it does not match the existing one (meaning, something new exists), I clear the cache and reindex all the posts. It is simplistic but works great for most cases.

I just tried your use case and you are right, if you unpublish or delete a post, nothing happens because the latest ‘updated_at’ post do not change. I will figure out the best approach and I hope I will get enough free time to release a new version this week-end :slight_smile:

About the “v2”, I think you are referring to the Ghost API version itself. For now, the majority of Ghost search engine uses the older v2 version because did not take time to upgrade to the “v3” (which is used by SearchinGhostEasy).

1 Like

Just to clarify what I mean by “v2”, certain themes use the Content API key to fetch posts from your site, and they also use a search index migration version, usually starting at “v1” to re-index the pages.

If you click show original and scroll to the Search header, you’ll see what I mean.

Thanks for the hint. It is the first theme I saw that provides this kind of smart “hack”, really interesting! I went through the code and I call that a hack because it gives you flexibility to invalidate the cache BUT you need to think about it and do a manual action any time you delete or unpublish a post.

For SearchinGhostEasy, I am really looking for a seamless experience that “just works” out of the box. So what I am thinking about is adding an extra step to check the total number of public posts. If at least one is missing, I trigger a cache refresh.

Let me know what you think about this. I will publish a message here when the release goes out :smiley:

That sounds like an excellent idea. I really look forward to the new release, and thanks @gmfmi for being so open and receptive towards making these changes. It’s really inspiring to see someone invested in making their product the best it can be for it’s users.

1 Like

The new release is out! Normally, you have nothing to do to be up to date. It should be automatic thanks to the @latest in the URL. Please, let me know if you have any trouble.

Thank you for the kind words, it is always a pleasure to see that it can truly helps people.

2 Likes

I am in the soft launch of my site - migrating from two others platforms to Ghost using the aEsto theme from @inoryum … who has done all the heavy lifting, including installing SearchinGhostEASY. I am a real fan of the plugin’s speed and simplicity but (you knew it was coming I have some questions about features and limits.

Features

  • Is there a way to make the search term and results persistent across page loads?
  • Is there a way to add the first tag to the displayed results? It can be on the same line as the date in the same CSS class – it does not need to be clickable but that’d be nice.
  • The order the results are returned seems to be random. Any way to alpha or date sort?

Limits

  • I have about 450 posts (new and imported) at the moment. I am going to be adding (importing) at least another 500 or so in the next week with a third tranche from an archive that could easily add over 1000 more. What’s the upper limit in terms of the number of posts SearchinGhostEASY can handle without straining? I am running a basic Digital Ocean virtual droplet (1 vCPU, 2 GB RAM, 25 GB disk) at the moment but can increase RAM/CPU/disk if need be.
1 Like

Hi @TheChocolateLife, thank you for the feed backs.

About limitation, there is no “hard” limit on the total number of posts BUT there is a limitation due to the maximum content size storable in a web browser. To be clear, it will work with 10.000 articles containing only 1 word OR 100 articles containing more than 1000 words BUT not with 1000 article containing 1000 words (all the numbers here are completely theoretical). Oh, and your server resources have NO impact on research, everything is made on the client side, so no worries about CPU or RAM :smiley:

SearchinGhostEASY uses the default parameters of the underlying SearchinGhost. By default, it uses the article body to run full-text search which took a lot of space in the browser storage. So in your case, you will probably want to turn off that feature and only search through article titles so you won’t get any limitation on your number of article. To do so, you will need to patch the aEsto theme to add an extra configuration parameter :

new SearchinGhostEasy({
    contentApiKey: content_key,
    apiUrl: api_url,
    searchinghostOptions: {
        postsFields: ['title', 'url', 'published_at'],
        postsExtraFields: ['tags'],
        postsFormats: [],
        indexedFields: ['title'],
        template: function (post) {
            var formattedTag = "";
            if (post.tags.length > 0) {
                formattedTag = ' #' + post.tags[0].name;
            }
            return `<a href="${post.url}"><time>${post.published_at}${formattedTag}</time><h2>${post.title}</h2></a>`
        }
    }
});

I also included an example of the “template” function. It’s quick and dirty, not tested and not semantically correct but it should work and solve your question about adding the article main tag :slight_smile:

Now, for features :

  • Why would you keep results persistant across pages ?
  • Based on the sample above, feel free to tweak the HTML template to feet your needs. If you need something else or if you struggle to much to set it up, send my a PM
  • Actually, the results order is not random. It is based on the article relevance score computed by FlexSearch (the search engine of searchinghost itself). For now, there is no way to sort the displayed result in any other way :confused:

I hope you will find this answer useful !

Hello,

The search bar is not working on my Chrome browser on Android. Desktop works fine though.

used code below in footer and changed version to 1.0.2 and deleted that line with no success

new SearchinGhostEasy({
contentApiKey: ‘<CONTENT_API_KEY>’, // mandatory
apiUrl: ‘http://example.com’,
searchinghostOptions: {},
searchinghostVersion: ‘1.0.0’,
zIndex: 200,
placeholder: “Search”,
debug: false
});