Learn about Microsoft Technologies, eGovernance, Smart Businesses and more

Mini-Tech Series

Elastic Search and What have we learned?

Author: Nemanja Svorcan
Elasticsearch (ES) is an open source in-memory document store written in Java and originally built on the Apache Lucene library.
What we need from ES:
1. Fast - Search results should be returned almost instantly, in order to provide a responsive user experience.

2. Flexible - We want to be able to modify how the search is performed, in order to optimize for different datasets and use cases.

3. Forgiving - If a search contains a typo, we'd still like to return relevant results for what the user might have been trying to search for.

4. FullText - We don't want to limit our search to specific matching keywords or tags - we want to search everything in our data-store (including large text fields) for a match.

ES stores complex data structures that have been serialized as JSON documents. At its core, ES is able to provide fast and flexible full-text search through the use of inverted indexes. An index can be thought of as an optimized collection of documents and each document is a collection of fields, which are the key-value pairs that contain your data. For example, we can have an index for customer data and another one for a product information.

An index is identified by a unique name that refers to the index when performing indexing search, update, and delete operations. In a single cluster, we can define as many indexes as we want. Index = database schema in an RDBMS (relational database management system) — similar to a database or a schema. Consider it a set of tables with some logical grouping. In Elasticsearch terms: index = database; type = table; document = row. ES also has the ability to be schema-less, which means that documents can be indexed without explicitly specifying how to handle each of the different fields that might occur in a document.
Elastic Search and .NET how does it fit in?
There are two official .NET clients for ES:

Elasticsearch .Net and NEST

Elasticsearch .Net is a very low level, dependency free, client that has no opinions about how you build and represent your requests and responses.

NEST is a high-level client that maps all requests and responses as types, and comes with a strongly typed query DSL that maps 1 to 1 with the Elastic search query DSL. It takes advantage of specific .NET features to provide higher level abstractions such as auto mapping of CLR types.

ElasticSearch can be used whenever we need search functionality on our site, whether that search is for documents (content, meta-data) or for regular metadata. Last attached link shows us how to work with SQL server data and to add it to index in ES. Only thing we should keep in mind is that data (no matter from which source) is indexed and stored in our local drive. So basically, depending from how large data source do we have, our index will grow with it.