SlideShare a Scribd company logo
1 of 6
How to Build A Search Page With
ElasticSearch and .Net
ElasticSearch is credited to achieve fast search responses because it
searches an index instead of searching the context directly.
Very much like retrieving pages in a book related to a word by scanning
the index at the back of a book, as instead of searching every word in
every page of the book.
This type of index is known as the inverted index because it inverts a
page-centric data structure (page->words) to a keyword-centric data
structure (word->pages).
This uses Apache Lucene to create and manage this inverted index.
NEST
To interact with Elasticsearch, NEST 2.3.0 is used which is one of two
official .NET clients for Elasticsearch. NEST is a high-level client which
tracks closely to Elasticsearch API. All the request and response objects
are mapped. NEST provides the alternatives of either a syntax for
creating queries, which resembles the structure of raw JSON requests to
API, or the use of object initializer syntax.
In order to build a web page, use Single Page Application (SPA)
approach with AngularJS as MVVM framework. The client side will send
AJAX requests to ASP.NET Web API 2. The Web API 2 controller will use
NEST to communicate with Elasticsearch.
Installation of Elasticsearch
Visit the web page, download an installer, unzip it and install in the
mentioned three simple steps. It exposes an HTTP API so it is easy to
use cURL to make requests but its recommended to use Sense which is
Chrome extension. The Elasticsearch reference contains samples in a
format called cURL.
Although Elasticsearch is able to resolve the document type and its
fields at index time, field mappings can be override or use attributes on
fields in order to give for more advanced usages.
In this example, the POCO class is decorated with some attributes so
we need to create mappings with AutoMap.
After defining our mappings and created an index, we can seed it with
documents. Elasticsearch does not give any handler to import specific
file formats such as XML or CSV, but because it has client libraries for
different languages, it is easy to build your own importer. As
StackOverflow dump is in XML format, use .NET XmlReader class to
read question rows, map them to an instance of Post and add objects to
the collection.
With this we conclude for today, stay connected with us for further
discussion on this in our next article.
If you want to learn ASP.Net and perfect yourself in .NET training, then
CRB Tech Solutions would be of great help and support for you. Join us
with our updated program in ASP.Net course.
Stay tuned to CRB Tech reviews for more technical optimization and
other resources.
Thank You.....!

More Related Content

Viewers also liked

MOST® ICA Program Focuses on Latest MOST150 Implementations and Applications
MOST® ICA Program Focuses on Latest MOST150 Implementations and ApplicationsMOST® ICA Program Focuses on Latest MOST150 Implementations and Applications
MOST® ICA Program Focuses on Latest MOST150 Implementations and Applicationsalvacon
 
06 estadistica 2015 - practica
06   estadistica 2015 - practica06   estadistica 2015 - practica
06 estadistica 2015 - practicaMiguel Zajama
 
Empoderamiento, redes sociales y cambio de ocio
Empoderamiento, redes sociales y cambio de ocioEmpoderamiento, redes sociales y cambio de ocio
Empoderamiento, redes sociales y cambio de ocioJoan Fernando Chipia Lobo
 

Viewers also liked (7)

Tributação de contratos de PI
Tributação de contratos de PITributação de contratos de PI
Tributação de contratos de PI
 
MOST® ICA Program Focuses on Latest MOST150 Implementations and Applications
MOST® ICA Program Focuses on Latest MOST150 Implementations and ApplicationsMOST® ICA Program Focuses on Latest MOST150 Implementations and Applications
MOST® ICA Program Focuses on Latest MOST150 Implementations and Applications
 
Renovação do Sistema Geral de Preferências Europeu (SGP)
Renovação do Sistema Geral de Preferências Europeu (SGP)Renovação do Sistema Geral de Preferências Europeu (SGP)
Renovação do Sistema Geral de Preferências Europeu (SGP)
 
Tarea de camilo
Tarea de camiloTarea de camilo
Tarea de camilo
 
TAXAS MODERADORAS
TAXAS MODERADORASTAXAS MODERADORAS
TAXAS MODERADORAS
 
06 estadistica 2015 - practica
06   estadistica 2015 - practica06   estadistica 2015 - practica
06 estadistica 2015 - practica
 
Empoderamiento, redes sociales y cambio de ocio
Empoderamiento, redes sociales y cambio de ocioEmpoderamiento, redes sociales y cambio de ocio
Empoderamiento, redes sociales y cambio de ocio
 

More from sonia merchant

What does dot net hold for 2016?
What does dot net hold for 2016?What does dot net hold for 2016?
What does dot net hold for 2016?sonia merchant
 
What does .net hold for 2016?
What does .net hold for 2016?What does .net hold for 2016?
What does .net hold for 2016?sonia merchant
 
Data protection api's in asp dot net
Data protection api's in asp dot netData protection api's in asp dot net
Data protection api's in asp dot netsonia merchant
 
Authorization in asp dot net part 2
Authorization in asp dot net part 2Authorization in asp dot net part 2
Authorization in asp dot net part 2sonia merchant
 
Asp dot-net core problems and fixes
Asp dot-net core problems and fixes Asp dot-net core problems and fixes
Asp dot-net core problems and fixes sonia merchant
 
Search page-with-elasticsearch-and-dot-net
Search page-with-elasticsearch-and-dot-netSearch page-with-elasticsearch-and-dot-net
Search page-with-elasticsearch-and-dot-netsonia merchant
 
How to optimize asp dot-net application
How to optimize asp dot-net applicationHow to optimize asp dot-net application
How to optimize asp dot-net applicationsonia merchant
 
How to optimize asp dot net application ?
How to optimize asp dot net application ?How to optimize asp dot net application ?
How to optimize asp dot net application ?sonia merchant
 
Learn dot net attributes
Learn dot net attributesLearn dot net attributes
Learn dot net attributessonia merchant
 
Learn about dot net attributes
Learn about dot net attributesLearn about dot net attributes
Learn about dot net attributessonia merchant
 
Owin and-katana-overview
Owin and-katana-overviewOwin and-katana-overview
Owin and-katana-overviewsonia merchant
 
Top 15-asp-dot-net-interview-questions-and-answers
Top 15-asp-dot-net-interview-questions-and-answersTop 15-asp-dot-net-interview-questions-and-answers
Top 15-asp-dot-net-interview-questions-and-answerssonia merchant
 
Next generation asp.net v next
Next generation asp.net v nextNext generation asp.net v next
Next generation asp.net v nextsonia merchant
 
Dot net universal apps
Dot net universal appsDot net universal apps
Dot net universal appssonia merchant
 
Browser frame building with c# and vb dot net
Browser frame building  with c# and vb dot netBrowser frame building  with c# and vb dot net
Browser frame building with c# and vb dot netsonia merchant
 
A simplest-way-to-reconstruct-.net-framework
A simplest-way-to-reconstruct-.net-frameworkA simplest-way-to-reconstruct-.net-framework
A simplest-way-to-reconstruct-.net-frameworksonia merchant
 
Silverlight versions-features
Silverlight versions-featuresSilverlight versions-features
Silverlight versions-featuressonia merchant
 

More from sonia merchant (20)

What does dot net hold for 2016?
What does dot net hold for 2016?What does dot net hold for 2016?
What does dot net hold for 2016?
 
What does .net hold for 2016?
What does .net hold for 2016?What does .net hold for 2016?
What does .net hold for 2016?
 
Data protection api's in asp dot net
Data protection api's in asp dot netData protection api's in asp dot net
Data protection api's in asp dot net
 
Authorization p iv
Authorization p ivAuthorization p iv
Authorization p iv
 
Authorization iii
Authorization iiiAuthorization iii
Authorization iii
 
Authorization in asp dot net part 2
Authorization in asp dot net part 2Authorization in asp dot net part 2
Authorization in asp dot net part 2
 
Asp dot-net core problems and fixes
Asp dot-net core problems and fixes Asp dot-net core problems and fixes
Asp dot-net core problems and fixes
 
Search page-with-elasticsearch-and-dot-net
Search page-with-elasticsearch-and-dot-netSearch page-with-elasticsearch-and-dot-net
Search page-with-elasticsearch-and-dot-net
 
How to optimize asp dot-net application
How to optimize asp dot-net applicationHow to optimize asp dot-net application
How to optimize asp dot-net application
 
How to optimize asp dot net application ?
How to optimize asp dot net application ?How to optimize asp dot net application ?
How to optimize asp dot net application ?
 
10 things to remember
10 things to remember10 things to remember
10 things to remember
 
Learn dot net attributes
Learn dot net attributesLearn dot net attributes
Learn dot net attributes
 
Learn about dot net attributes
Learn about dot net attributesLearn about dot net attributes
Learn about dot net attributes
 
Owin and-katana-overview
Owin and-katana-overviewOwin and-katana-overview
Owin and-katana-overview
 
Top 15-asp-dot-net-interview-questions-and-answers
Top 15-asp-dot-net-interview-questions-and-answersTop 15-asp-dot-net-interview-questions-and-answers
Top 15-asp-dot-net-interview-questions-and-answers
 
Next generation asp.net v next
Next generation asp.net v nextNext generation asp.net v next
Next generation asp.net v next
 
Dot net universal apps
Dot net universal appsDot net universal apps
Dot net universal apps
 
Browser frame building with c# and vb dot net
Browser frame building  with c# and vb dot netBrowser frame building  with c# and vb dot net
Browser frame building with c# and vb dot net
 
A simplest-way-to-reconstruct-.net-framework
A simplest-way-to-reconstruct-.net-frameworkA simplest-way-to-reconstruct-.net-framework
A simplest-way-to-reconstruct-.net-framework
 
Silverlight versions-features
Silverlight versions-featuresSilverlight versions-features
Silverlight versions-features
 

Recently uploaded

French Revolution (फ्रेंच राज्यक्रांती)
French Revolution  (फ्रेंच राज्यक्रांती)French Revolution  (फ्रेंच राज्यक्रांती)
French Revolution (फ्रेंच राज्यक्रांती)Shankar Aware
 
30 ĐỀ PHÁT TRIỂN THEO CẤU TRÚC ĐỀ MINH HỌA BGD NGÀY 22-3-2024 KỲ THI TỐT NGHI...
30 ĐỀ PHÁT TRIỂN THEO CẤU TRÚC ĐỀ MINH HỌA BGD NGÀY 22-3-2024 KỲ THI TỐT NGHI...30 ĐỀ PHÁT TRIỂN THEO CẤU TRÚC ĐỀ MINH HỌA BGD NGÀY 22-3-2024 KỲ THI TỐT NGHI...
30 ĐỀ PHÁT TRIỂN THEO CẤU TRÚC ĐỀ MINH HỌA BGD NGÀY 22-3-2024 KỲ THI TỐT NGHI...Nguyen Thanh Tu Collection
 
Seth-Godin-–-Tribus-PDFDrive-.pdf en espaoñ
Seth-Godin-–-Tribus-PDFDrive-.pdf en espaoñSeth-Godin-–-Tribus-PDFDrive-.pdf en espaoñ
Seth-Godin-–-Tribus-PDFDrive-.pdf en espaoñcarrenoelio8
 
TUYỂN TẬP 25 ĐỀ THI HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2023 CÓ ĐÁP ÁN (SƯU...
TUYỂN TẬP 25 ĐỀ THI HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2023 CÓ ĐÁP ÁN (SƯU...TUYỂN TẬP 25 ĐỀ THI HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2023 CÓ ĐÁP ÁN (SƯU...
TUYỂN TẬP 25 ĐỀ THI HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2023 CÓ ĐÁP ÁN (SƯU...Nguyen Thanh Tu Collection
 
TUYỂN TẬP 20 ĐỀ THI KHẢO SÁT HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2020 (CÓ Đ...
TUYỂN TẬP 20 ĐỀ THI KHẢO SÁT HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2020 (CÓ Đ...TUYỂN TẬP 20 ĐỀ THI KHẢO SÁT HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2020 (CÓ Đ...
TUYỂN TẬP 20 ĐỀ THI KHẢO SÁT HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2020 (CÓ Đ...Nguyen Thanh Tu Collection
 

Recently uploaded (6)

French Revolution (फ्रेंच राज्यक्रांती)
French Revolution  (फ्रेंच राज्यक्रांती)French Revolution  (फ्रेंच राज्यक्रांती)
French Revolution (फ्रेंच राज्यक्रांती)
 
30 ĐỀ PHÁT TRIỂN THEO CẤU TRÚC ĐỀ MINH HỌA BGD NGÀY 22-3-2024 KỲ THI TỐT NGHI...
30 ĐỀ PHÁT TRIỂN THEO CẤU TRÚC ĐỀ MINH HỌA BGD NGÀY 22-3-2024 KỲ THI TỐT NGHI...30 ĐỀ PHÁT TRIỂN THEO CẤU TRÚC ĐỀ MINH HỌA BGD NGÀY 22-3-2024 KỲ THI TỐT NGHI...
30 ĐỀ PHÁT TRIỂN THEO CẤU TRÚC ĐỀ MINH HỌA BGD NGÀY 22-3-2024 KỲ THI TỐT NGHI...
 
Seth-Godin-–-Tribus-PDFDrive-.pdf en espaoñ
Seth-Godin-–-Tribus-PDFDrive-.pdf en espaoñSeth-Godin-–-Tribus-PDFDrive-.pdf en espaoñ
Seth-Godin-–-Tribus-PDFDrive-.pdf en espaoñ
 
TUYỂN TẬP 25 ĐỀ THI HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2023 CÓ ĐÁP ÁN (SƯU...
TUYỂN TẬP 25 ĐỀ THI HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2023 CÓ ĐÁP ÁN (SƯU...TUYỂN TẬP 25 ĐỀ THI HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2023 CÓ ĐÁP ÁN (SƯU...
TUYỂN TẬP 25 ĐỀ THI HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2023 CÓ ĐÁP ÁN (SƯU...
 
LAR MARIA MÃE DE ÁFRICA .
LAR MARIA MÃE DE ÁFRICA                 .LAR MARIA MÃE DE ÁFRICA                 .
LAR MARIA MÃE DE ÁFRICA .
 
TUYỂN TẬP 20 ĐỀ THI KHẢO SÁT HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2020 (CÓ Đ...
TUYỂN TẬP 20 ĐỀ THI KHẢO SÁT HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2020 (CÓ Đ...TUYỂN TẬP 20 ĐỀ THI KHẢO SÁT HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2020 (CÓ Đ...
TUYỂN TẬP 20 ĐỀ THI KHẢO SÁT HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2020 (CÓ Đ...
 

Build a-search-page-with-elastic search-and-dot-net

  • 1. How to Build A Search Page With ElasticSearch and .Net
  • 2. ElasticSearch is credited to achieve fast search responses because it searches an index instead of searching the context directly. Very much like retrieving pages in a book related to a word by scanning the index at the back of a book, as instead of searching every word in every page of the book. This type of index is known as the inverted index because it inverts a page-centric data structure (page->words) to a keyword-centric data structure (word->pages). This uses Apache Lucene to create and manage this inverted index.
  • 3. NEST To interact with Elasticsearch, NEST 2.3.0 is used which is one of two official .NET clients for Elasticsearch. NEST is a high-level client which tracks closely to Elasticsearch API. All the request and response objects are mapped. NEST provides the alternatives of either a syntax for creating queries, which resembles the structure of raw JSON requests to API, or the use of object initializer syntax. In order to build a web page, use Single Page Application (SPA) approach with AngularJS as MVVM framework. The client side will send AJAX requests to ASP.NET Web API 2. The Web API 2 controller will use NEST to communicate with Elasticsearch.
  • 4. Installation of Elasticsearch Visit the web page, download an installer, unzip it and install in the mentioned three simple steps. It exposes an HTTP API so it is easy to use cURL to make requests but its recommended to use Sense which is Chrome extension. The Elasticsearch reference contains samples in a format called cURL. Although Elasticsearch is able to resolve the document type and its fields at index time, field mappings can be override or use attributes on fields in order to give for more advanced usages. In this example, the POCO class is decorated with some attributes so we need to create mappings with AutoMap.
  • 5. After defining our mappings and created an index, we can seed it with documents. Elasticsearch does not give any handler to import specific file formats such as XML or CSV, but because it has client libraries for different languages, it is easy to build your own importer. As StackOverflow dump is in XML format, use .NET XmlReader class to read question rows, map them to an instance of Post and add objects to the collection. With this we conclude for today, stay connected with us for further discussion on this in our next article. If you want to learn ASP.Net and perfect yourself in .NET training, then CRB Tech Solutions would be of great help and support for you. Join us with our updated program in ASP.Net course. Stay tuned to CRB Tech reviews for more technical optimization and other resources.