Elasticsearch is completely document-oriented and it stores entire documents in its index. But you need to to create a client to communicate with Elasticsearch.
Building A Search Page with Elasticsearch and .NET- II
1. Part – II
Building A Search Page with
Elasticsearch and .NET
.Net Training Instuitute In Pune
2. Search index population
Elasticsearch is completely document-oriented and it stores entire
documents in its index. But you need to to create a client to communicate
with Elasticsearch.
Elasticsearch is known to dynamically resolve the document type and its
fields at index time,one can override field mappings or use features on
fields in order to give more advanced usages. In the below example we
decorated our POCO class with some features so we need to develop
mappings with AutoMap.
.Net Training Instuitute In Pune
3. Full text search
The search method will perform the multi-match query against user
input. The multi-match query is useful while running the query against
multiple fields. By using this, we can see how relevant the Elasticsearch
results are with the default configuration.
First, you require calling the Query method that is a container for any
specific query we want to perform. Next, call the MultiMatch method
which calls the Query method with the actual search phrase as a
parameter and a list of fields that you want to search against. In our
context, these are Title, Body, and Tags.
.Net Training Instuitute In Pune
4. How to group by tags
Once the search returns results, we would group them by tags so that
users can refine their search. In order to cluster group result as
categories, we use the bucket aggregations. They allow as to compose
bucket of documents which falls into given criteria or not. As we want to
cluster by tags, which is a text field, we will use the term aggregations.
It commands Elasticsearch to neither analyze nor process the input and
to find the field. It would not change ‘unit-testing’ tag to ‘unit’ and ‘testing’
etc.
Now, extending the search result class with a dictionary containing the
tag name and the number of posts designed with this tag.
.Net Training Instuitute In Pune.Net Training Instuitute In Pune
5. One of the features that are frequently used in search forms is
autocompleted.
Searching big sets of text data by only a few characters is not an easy
task. Elasticsearch provides us completion suggester which works on a
special field that is recorded in a way that helps very fast searching.
You need to decide which field or fields you want to autocomplete to act
on and what results will be suggested. Elasticsearch enables to define
both input and output.
.Net Training Instuitute In Pune
6. Summary
Installation and configuration of Elasticsearch are very easy. The default
configuration choices are just right to start working with. Elasticsearch
doesn’t need a schema file and reveals a friendly JSON-based HTTP API
for its configuration, index-population, and searching. The engine is
optimized to work with a large amount of data.
You need a high-level .NET client to communicate with Elasticsearch so
it fits nicely in .NET project.
Elasticsearch is an advanced search engine with many attributes and its
own query DSL.
.Net Training Instuitute In Pune