Search made simple - SearchinGhostEASY

Hi @andrewdefries,

I am not quite sure of your issue root cause but if you are using the default parameters, you should probably set the minimum number of parameters. For example, copy and paste the following in your footer script section :

<script src="https://cdn.jsdelivr.net/gh/gmfmi/searchinghost-easy@latest/dist/searchinghost-easy-basic.js"></script>
<script>
    new SearchinGhostEasy({
        contentApiKey: '<CONTENT_API_KEY>', // do not forget to replace this with your own key
        debug: true
    });
</script>

Then, if nothing shows up, go to your browser console to see if anything is logged :wink:

Generally, on mobile device, the issue comes from local storage and cache. Try from a “private browsing” tab to see if it works.

Hello,

I pasted your code with my cotent api key and private browsing on mobile did not fix this.

As I mentioned previously the search function is not coming through on my mobile Android Chrome browser. Works just great on desktop!

Does the search work for you on mobile?
http://134.122.9.102/

Features:

Persistence: Sometimes a search result on a common term will return 10 or more results as everything on my site (thechocolatelife.com) shares a common topic. I click on one result, it’s not what I want. I’ve opened a new page and the search has been cleared. I then need to re-enter the search term. Persistence would mean the last search term was pre-populated and the search would be done again without requiring user input. Saving time. This should probably be a configuration option.

A nice UI/UX refinement would be to add a “clear this search” icon/function in the search text box.

I would recommend talking to the FlexSearch people about adding sort options. Sometimes I want to know the oldest result, sometimes the newest – and so “relevance” is not relevant to me. I know the post date is in the result – but it’s a pretty heavy cognitive burden to read through every result for the oldest/newest article when there are many.

@inoryum let’s discuss tuning the search parameters when all the new articles are added – and adding the tag to the search results template.

Hi @andrewdefries,

Sorry for the late reply, I checked you website and the issue is not coming from the search plugin itself but from the menu displayed for mobile. For example, I you resize you web browser to be as thin as a tablet or a mobile, you will get the exact same issue on a laptop.

I did not dig deeper but you should take a closer look on the theme side. Try to know why the link /#searchinghost-easy is called instead of just #searchinghost-easy. Because of that, a page reload is triggered so you will never see the search box.

Which you luck to debug :slight_smile:

Thank you for the explanation. I never though it this way but that is very interesting. I am very busy right now but I really hope I will find some free time to implement the “persistence” feature.

About the sort option, though it is technically feasible, it would required dedicated development and that goes beyond the SearchinGhost “tool for everyone” scope. But, an option is to always sort the displayed results with the newest first. And you can do that on your own :wink:

I have to say it but
 going on your blog is a torture. I love chocolate and now the only thing I can think of is
 to eat any bite of chocolate I can find in my house ! :see_no_evil:

I also saw that, with 446 posts, you exceeded the quota allowed by browsers. Now, you should definitely think of indexing only posts titles to give a smoother experience to your users.

Thanks for letting me know about hitting the limit. This in-browser memory limit is a FlexSearch limit? Just confirming.

Nothing to do with FlexSearch, it is purely a browser limitation. You can check this stackoverflow thread for more details.

And just to be clear, what we store is a JSON representation of the built index from FlexSearch. So when you use the default “full-text indexation”, you actually try to store all your articles content in the visitor browser. That is why getting rid of the content will fix the issue.

@gmfmi thanks for the clarification about how SearchinGhostEASY works. Obviously it is not scalable to load every word of every post into memory and index it there.

I think the question I was really trying to ask was about using FlexSearch with Ghost to get around the memory limitation. My members are used to have full-text search, not just the ability to search the post titles.

When you say “FlexSearch with Ghost”, do you mean “running FlexSearch on the server side, so the client will send a request at each key stroke with its search word, it will be proceed by the server and then a response will be send back to the client” ? Just to be sure.

If it is what you meant, it is totally doable but that is a whole different story. I think it would take about 3 days to setup something ready for production (nodejs code, integration and security concerns). But I don’t know if it is a good idea. At that point, maybe it would be smarter to go with already existing full-fledge solution like MeiliSearch, Elasticsearch or equivalent.

What would be really awesome is to setup an integration plugin accessible from the native Ghost admin panel. But for now, I did not find documentation about it
 :confused:

Much to ponder here, in a very good way.

I have been investigating GhostHunter and Typesense (leaning towards Typesense). I have some experience with Elastic Search but with awesome power comes a lot more admin overhead than I want to support. MeiliSearch seems like it might be easier to install and maintain than Typesense, and I especially like the thesaurus capabilities, which are attractive for a tightly focused content site like mine (cocoa and chocolate) and I want to deploy a thesaurus, anyway.

An API integration into the Ghost Admins is appealing for a bunch of reasons and so something to consider as well.

I love SearchinGhostEasy and have been using it for a while, but all of a sudden it doesn’t work on my site. Is anyone else having the same issue?

Michell LĂ©on

Hi Michell,

I double checked but I don’t think this is global issue. For instance, the demo website is currently working as expected (here).

Could you give us the URL of your site ? If you prefer to keep this information private, feel free to send it to me using a private message.

Cheers!

Thanks for getting back to me. Yes, it’s odd. Can’t figure it out. You’re welcome to check the site. It’s www.fiveelementwriting.com

Michell

image

It looks like custom integrations aren’t supported on your hosting plan, which doesn’t allow the search plugin to access your posts via the API


Thanks @TheRoyalFig! I came to the same conclusion, the issue directly comes from your hosting platform limitations.

Now, it is up to you, you can either upgrade to a higher tier or give a try to another hosting company.

1 Like

Ah, that’s why. And pretty annoying too, because I specifically asked Ghost if I could include code injections at the low tier, and they said yes. Since this search function is nothing but a code injection one should be allowed to use it, I think. I will have a chat with them about it. Hopefully they see it this way too.

Thanks for your help so far.
Michell

1 Like

Thanks for this great search tool - perfect for non-coders like me.
I’ve just added a collection to my site for newsletters and excluded these posts (tagged newsletter) from the home page.
Is there a way I could exclude the newsletter posts from the search results?
Thanks
Pete

Hi @petem64, thank you for the kind words. Good news, I got a solution for you :wink:.

To discard all posts from a specific category (which are actually tags), you can remove them in the customProcessing of the searchinghost inner library. I tested on your website posts and it works well. Here is working example configuration:

new SearchinGhostEasy({
  contentApiKey: '...',
  searchinghostOptions:{
      customProcessing: function(post) {
          if (post.tags) post.string_tags = post.tags.map(o => o.name).join(' ').toLowerCase();
          // discard any 'newsletter' post
          for (tag of post.tags) {
              if (['newsletter'].includes(tag.slug)) {
                  return null;
              }
          }
          return post;
      }
  }
});

Here, I excluded any post with a newsletter tag. If you need to exclude several types of posts, simply add other tags to the list.

If it is not clear enough, feel free to send me a DM.

Hope it helps!

1 Like

Thank you for this plugin, which really helps non-tech people like me.

I have everything installed, and the search link works at mattrutherford.co.uk however, I cannot get any results in my search.

Is there something else I might need to do to enable this? Any help would be gratefull recieved.

Hey @MattRutherford!

I quickly checked your website, the issue is coming from the API key format. Currently, you are using

<script>
    new SearchinGhostEasy({
        contentApiKey: '<d5860ecaaf38ccee869cdb6a67>'
    });
</script>

but the API key needs to be declared WITHOUT the extra brackets. To solve your issue, please replace the code above by the following one on your website:

<script>
    new SearchinGhostEasy({
        contentApiKey: 'd5860ecaaf38ccee869cdb6a67'
    });
</script>

Happy searching :slight_smile:

1 Like