Skip to main content

Posts

Showing posts from March, 2023

Play with Elasticsearch basic queries

Greetings In a previous article , we set up our environment to play with Elasticsearch. Let's try basic queries in this article by building a movie search. Unlike other databases, Elasticsearch gives full searching power. Let's slowly dig into that power. Hence this is not a deep dive. I use the top 250 movies from  imdb-api in this exercise. Movie database Let's build a movie database using imdb-api and play with queries. Save movies as documents Movies to contain text, numbers, arrays, full text Structured search using movie ratings, year Full-text search (title, actors) Phrase search (plot, title) Return highlighted search snippets Note: You can either use Kibana UI or a direct call to Elasticsearch. Hence I skip the URL path. curl -XPUT -H "Content-Type:application/json" localhost:9200/movies/_doc/tt0068646 -d ' { "title": "The Godfather", "year": 1972, "rating": 9.2 }' Indexing mov

Setup Elasticsearch playground

Greetings When learning new technology, installation is the first burden and it is irritating. However, in modern-day development, we developers usually don't have to bother too much with operations and there are dedicated teams assigned for that purpose. Let's see how we can get started with Elasticsearch. For someone who starts exploring Elasticsearch, there are two main options. Cloud free trial Docker container Cloud free trial This is the easiest way for someone new to Elasticsearch. You just register for the free trial without a credit card. The only drawback is it expires in 14 days. But that is enough for initial experience. If you know how to use emails with plus at the end, you can have endless accounts. https://www.elastic.co/cloud/elasticsearch-service/signup Docker container The other option is to spin up a Docker container. That is also an easy option. However, you need to know just enough Docker to use it. With Elasticsearch 8 security is enabled by d

Architecting seasonal offers using AWS serverless

Greetings! When I started writing lambda and serverless, I wanted to design a real-world project. The example that was in mind was a geolocation extractor using an image upload that my friend did. I thought to tweak it to an Excel file upload with another example that is based on real-world e-commerce requirements. What I want to focus on here is the architecture. Seasonal offers Offers are common in any business. Now the marketing team decides that having a separate section to indicate seasonal offers with additional descriptions would increase the orders. As they are experts in excel they say hey Devs, we don't want a UI for us. We will give you an excel to make your lives easier. Requirement Design a restful API to expose seasonal offers that are coming as an excel sheet. Technical breakdown We can store the excel in our code and directly read it. But that is not an expandable solution. Hence we store the file in an S3 bucket and separate out the extraction logic. Architecture

Migrate your (WordPress) website into a Microservice

Greetings We recently migrated our WordPress website into our microservices stack to maintain it within the same stack. It was a fun experience for me hence I'm sharing it with you so that you can learn from it. I will provide a high-level thinking process and the reasoning behind decisions. Note: The majority of this is still valid for non-WordPress websites as well. Option 1 - Direct database access WordPress uses MySql as the database to store posts. If you have full access to the database you can directly access it and fetch using your own queries. However, this was not our case luckily haha. Unless we would not get this learning experience. Option 2 - Selenium We started with the selenium web driver that runs through the Chrome web browser. Selenium gave us a perfect solution that scraped all necessary information. With selenium, we can navigate through pages, click on links and navigate to sub-pages. When we navigate to the desired page we can utilize selenium-provided APIs t