Searching Related Documents With Elasticsearch

In my last article we learned how to get started with Elasticsearch. In this article we are going to learn some strategies for dealing with related documents.

Relationships

Relationships between documents depend on the type of data we are storing. Some examples of relationships:

  • Restaurants and locations, where a restaurant can have multiple locations, but a location can only belong to one restaurant. This is a one to many relationship.
  • Orders and users, where each order belongs to a user. A user can have multiple orders but an order belongs to a single user. Also, one to many.
  • Movies and actors. A movie can star multiple actors and an actor can star in multiple movies. Many to many relationship.
Read More

Introduction to Elasticsearch

Why do I need a search engine?

Search is everywhere. We use Google to find websites, we search for products in Amazon, we use keywords to find videos on Youtube, etc.

From the consumer side, it’s a great way to get the information we need quickly. From the producer side, it means that we need to make sure we provide this interface the users have come to expect.

Relational or document databases allow us to create indices and find pieces of information based on ids, but they don’t work for searching for various keywords inside a text or when there are typos or synonyms involved. This is where search engines become useful; when we need to index unstructured data and offer flexible search capabilities.

Read More

Monitoring Kubernetes Resources with Fabric8 Informers

In my previous article we learned how to use the fabric8 java kubernetes client. In this article we are going to explore their Informer API.

The Informer API can be used to monitor Kubernetes resources (pods, services, etc.). This can be useful for a number of things like performing actions when a resource is created, destroyed, etc.

Using Informers

Informers are used to monitor Kubernetes resources. We create an informer with SharedInformerFactory:

Read More

Kubernetes Java Client

If you are getting started with Kubernetes, you probably have been using kubectl to perform operations on your cluster. Kubectl is a client library that communicates with the Kubernetes cluster using the Kubernetes API.

In this article we are going to learn how to use the Kubernetes Java Client to communicate with our cluster from a Java program.

Installation

We can find the up-to-date instructions at the official installation documentation.

For Bazel, we need to have the maven repository configured in the workspace and the client-java artifact:

Read More

Resource Management in Kubernetes - Requests and Limits

This article assumes some basic knowledge of Kubernetes. If you need an introduction to Kubernetes you can look at:

Why do we need to know about requests and limit

If we tried to run a pod that requires 8GB of memory in a host that only has 4GB of memory, the host would run out of memory and it would crash. In this article we are going to learn how to specify how much resources a pod needs so the scheduler can make better decisions about where to run pods.

Read More

Kubernetes ConfigMaps

It’s common for applications to require some kind of configuration. These configurations make it easy to change settings depending on the environment where the application is running.

For example, we might want to connect to a back-end server when running in a testing environment, but to a different one when running in production. An application might read these settings from environment variables, configuration files, or other means.

ConfigMaps are a way to make configurations available to pods so they can be used by our applications.

Read More

Command Line Efficiency With Tmux

I’m a a Software Developer that uses Ubuntu as his main OS and Vim as his main editor. I like Ubuntu (more specifically Gnome) because it allows me to move windows around without having to use the mouse. If I need to maximize a window, move a window to a different screen or split the screen between two windows, I just need to type a keyboard shortcut.

When I’m focused on writing or reading code, Vim also allows me to move around the code easily without a mouse.

Tmux is a tool that allows us to expand the capabilities of the terminal so we can manipulate terminal panes similar to how we can manipulate windows with Gnome, or navigate code in a similar fashion as with Vim.

Read More

Verifying Github commits with GPG

At the time of this writing, Github is the most popular place to host open source projects on the internet. It has a lot of features that make it easy to collaborate, navigate the code, test, deploy, etc.

Since it’s so popular, it’s important to understand a little about how security works on Github.

Security

When we create a new repository on Github we are the only ones who are allowed to write to that repository.

If we want to allow other people to write to a repository we can add them as a collaborator. Collaborators have a lot of power, so they should be people we know well and trust.

Read More

Dependency injection (Inversion of Control) in Spring framework

In this article we are going to learn about one of the foundational pieces of the Spring Framework; its implementation of Dependency Injection (which they usually refer by the more confusing name: Inversion of Control or IoC).

If you don’t know what Dependency Injection is, you can start by reading the first section of my Dependency Injection with Dagger and Bazel article. That section explains what is dependency injection and how it’s typically used.

Spring Beans

The term bean is used to refer to a few things in the Java world, so it’s important to know what it means when used in the context of Spring.

A Spring bean refers to an object that is injected by Spring’s depedency injection framework (Usually referred as IoC framework or IoC container).

ApplicationContext

The ApplicationContext interface takes care of creation and injection of beans. There are different implementations of this interface that allow us to configure our beans using different methods. We’ll start by looking at the traditional way: ClassPathXmlApplicationContext.

Read More