Exeami have search now!

It's easier than you think

by Exeami

Search Micro Formats IndieWeb

Background

I always felt having a search in any website is useful, and I wanted to have one in mine. Even though I know how to exactly navigate to the content I want in my website, I sometimes feel lazy and wish I had a quick way to ask and get what I want.

The reasons why I want search are maybe obvious, but for some reason I had a feeling that it will be tough to implement and needs a lot of work till I actually did it. I had a fully functioning search which fits my requirements in less than a day of effort. That is the reason I wanted to write this blog to tell how easy it can be to have your own search in your website.

When I searched how to add to search to my website in a search engine, the most popular option is implementing search boxes from leading search engine providers. Most of the articles pointed out how to add these search boxes to my site. I leaned towards adding DuckDuckGo search box as I do not need to register to the service like google and as always I prefer DuckDuckGo. It took few minutes to add DuckDuckGo search box to my site, it works well, but I did not like the fact I will be redirected to DuckDuckGo. Pardon me with the metaphor, but it felt like I am leaving my home to search something from my home, and did it feel right. Then I realized that I need to implement custom search.

The next step in my search of adding search was to go and check in IndieWeb, where I found that Peter Molnar uses SQLite3 FTS4 engine for full text searching his site. That felt like a good way for me, but I did not get to see how he did it or any reference to his code. And I knew I had to do it my way, following the documentation.

The way I did it

On high level, my search is simple, I need a list of web pages to crawl, need to save the content of those pages in db, query the db and share the page link which matches my search query using FTS (Full Text Search).

Exeami was already structured with microformats as part of supporting Indie Web when I planned to implement search. So, I utilized this structure to crawl and store.

You can find the source code on Codeberg for micro search, named it "micro search" as its a search engine for sites supporting microformats2.

micro search exposes two api endpoints

  • a PUT request that crawls the webiste, find h-entry and stores p-name, p-category, p-summery, e-content as a row item.
  • a GET request that takes query parameter and returns the list of h-entry urls that matches the query text.

That's it, now Exeami have search functionality.

Comment via email

Recent Blogs

Getting to know IndieWeb2023-09-07

What is IndieWeb and why do you need to know about it?

Ownership IndieWeb

Once I was reading about how Amazon gave a platform for many small businesses to sell products online and how it helped them. You might even have heard that, but think about it, whenever we buy something from a small business on Amazon, we often relate it as we bought it from Amazon and never really remember the seller or the creator. This …

Why should I care about data privacy?2020-07-21

Six reasons why.

Data Privacy

Recently when I was speaking about data privacy to a friend, he said "How do I get affected if my data is collected, in a way I am getting personal suggestions, so it seems to be good, as I have nothing to hide?" We usually listen to this in various forms, from many people around us, so I want to bring this up to you. The way we think …

See all blogs