KEMBAR78
“Elasticsearch for .NET developers” | PPTX
Обо мне
.Net Fullstack developer,
MSP
C#
F#JS
AzureASP.NET
Http
Lucene
Why ?
Relational DB
▪ Databases
▪ Tables
▪ Rows
▪ Columns
Elastic Search
▪ Indexes
▪ Types
▪ Documents
▪ Fields
▪ Low-level client
▪ Generated from the official REST
API spec
▪ Unlike NEST, does not provide typed
request and response objects
▪ High level
▪ Strongly typed requests and
responses
▪ Advanced functionality
Elasticsearch .NET NEST
▪ Full text
▪ Term level
▪ Span
▪ Compound
▪ Geo
▪ Joining
▪ Specialized
Elasticsearch .NET
GET /_search
{
"query": {
"match" : {
"message" : “hellow world"
}
}
}
new MatchQuery
{
Field = Field<Project>(p => p.Description),
Query = "hello world",
}
▪ Full text
▪ Term level
▪ Span
▪ Compound
▪ Geo
▪ Joining
▪ Specialized
Elasticsearch .NET
"query": {
"term": {
"user": {
"value": "Kimchy",
"boost": 1.0
}
}
}
new TermQuery
{
Boost = 1.1,
Field = Field<Project>(p => p.Description),
Value = "project description"
}
▪ Full text
▪ Term level
▪ Span
▪ Compound
▪ Geo
▪ Joining
▪ Specialized
Elasticsearch .NET
{
"query": {
"span_term" : { "user" : { "value" : "kimchy", "boost" : 2.0 } }
}
}
new SpanTermQuery
{
Name = "named_query",
Boost = 1.1,
Value = "kimchy",
Field = "user"
}
▪ Full text
▪ Term level
▪ Span
▪ Compound
▪ Geo
▪ Joining
▪ Specialized
Elasticsearch .NET
POST _search
{
"query": {
"bool" : {
"must" : {
"term" : { "user" : "kimchy" }
},
"filter": {
"term" : { "tag" : "tech" }
},
"must_not" : {
"range" : {
"age" : { "gte" : 10, "lte" : 20 }
}
},
"should" : [
{ "term" : { "tag" : "wow" } },
{ "term" : { "tag" : "elasticsearch" } }
],
"minimum_should_match" : 1,
"boost" : 1.0
}
}
}
▪ Full text
▪ Term level
▪ Span
▪ Compound
▪ Geo
▪ Joining
▪ Specialized
Elasticsearch .NET
new GeoDistanceQuery
{
Boost = 1.1,
Name = "named_query",
Field = Infer.Field<Project>(p => p.Location),
DistanceType = GeoDistanceType.Arc,
Location = new GeoLocation(34, -34),
Distance = "200.0m",
ValidationMethod =
GeoValidationMethod.IgnoreMalformed
}
▪ Full text
▪ Term level
▪ Span
▪ Compound
▪ Geo
▪ Joining
▪ Specialized
Elasticsearch .NET
new NestedQuery
{
Name = "named_query",
Boost = 1.1,
InnerHits = new InnerHits { Explain = true },
Path = Field<Project>(p => p.CuratedTags),
Query = new TermsQuery
{
Field = Field<Project>(p =>
p.CuratedTags.First().Name),
Terms = new[] { "lorem", "ipsum" }
},
IgnoreUnmapped = true
}
▪ Full text
▪ Term level
▪ Span
▪ Compound
▪ Geo
▪ Joining
▪ Specialized
Elasticsearch .NET
{
"script": {
"_name": "named_query",
"boost": 1.1,
"script": {
"source": "doc['numberOfCommits'].value > param1",
"params": {
"param1": 50
}
}
}
}
new ScriptQuery
{
Name = "named_query",
Boost = 1.1,
Source = _templateString,
Params = new Dictionary<string, object>
{
{ "param1", 50 }
}
}
“Elasticsearch for .NET developers”
“Elasticsearch for .NET developers”
“Elasticsearch for .NET developers”
“Elasticsearch for .NET developers”

“Elasticsearch for .NET developers”

  • 2.
    Обо мне .Net Fullstackdeveloper, MSP C# F#JS AzureASP.NET
  • 3.
  • 4.
  • 7.
    Relational DB ▪ Databases ▪Tables ▪ Rows ▪ Columns Elastic Search ▪ Indexes ▪ Types ▪ Documents ▪ Fields
  • 9.
    ▪ Low-level client ▪Generated from the official REST API spec ▪ Unlike NEST, does not provide typed request and response objects ▪ High level ▪ Strongly typed requests and responses ▪ Advanced functionality Elasticsearch .NET NEST
  • 15.
    ▪ Full text ▪Term level ▪ Span ▪ Compound ▪ Geo ▪ Joining ▪ Specialized Elasticsearch .NET GET /_search { "query": { "match" : { "message" : “hellow world" } } } new MatchQuery { Field = Field<Project>(p => p.Description), Query = "hello world", }
  • 16.
    ▪ Full text ▪Term level ▪ Span ▪ Compound ▪ Geo ▪ Joining ▪ Specialized Elasticsearch .NET "query": { "term": { "user": { "value": "Kimchy", "boost": 1.0 } } } new TermQuery { Boost = 1.1, Field = Field<Project>(p => p.Description), Value = "project description" }
  • 17.
    ▪ Full text ▪Term level ▪ Span ▪ Compound ▪ Geo ▪ Joining ▪ Specialized Elasticsearch .NET { "query": { "span_term" : { "user" : { "value" : "kimchy", "boost" : 2.0 } } } } new SpanTermQuery { Name = "named_query", Boost = 1.1, Value = "kimchy", Field = "user" }
  • 18.
    ▪ Full text ▪Term level ▪ Span ▪ Compound ▪ Geo ▪ Joining ▪ Specialized Elasticsearch .NET POST _search { "query": { "bool" : { "must" : { "term" : { "user" : "kimchy" } }, "filter": { "term" : { "tag" : "tech" } }, "must_not" : { "range" : { "age" : { "gte" : 10, "lte" : 20 } } }, "should" : [ { "term" : { "tag" : "wow" } }, { "term" : { "tag" : "elasticsearch" } } ], "minimum_should_match" : 1, "boost" : 1.0 } } }
  • 19.
    ▪ Full text ▪Term level ▪ Span ▪ Compound ▪ Geo ▪ Joining ▪ Specialized Elasticsearch .NET new GeoDistanceQuery { Boost = 1.1, Name = "named_query", Field = Infer.Field<Project>(p => p.Location), DistanceType = GeoDistanceType.Arc, Location = new GeoLocation(34, -34), Distance = "200.0m", ValidationMethod = GeoValidationMethod.IgnoreMalformed }
  • 20.
    ▪ Full text ▪Term level ▪ Span ▪ Compound ▪ Geo ▪ Joining ▪ Specialized Elasticsearch .NET new NestedQuery { Name = "named_query", Boost = 1.1, InnerHits = new InnerHits { Explain = true }, Path = Field<Project>(p => p.CuratedTags), Query = new TermsQuery { Field = Field<Project>(p => p.CuratedTags.First().Name), Terms = new[] { "lorem", "ipsum" } }, IgnoreUnmapped = true }
  • 21.
    ▪ Full text ▪Term level ▪ Span ▪ Compound ▪ Geo ▪ Joining ▪ Specialized Elasticsearch .NET { "script": { "_name": "named_query", "boost": 1.1, "script": { "source": "doc['numberOfCommits'].value > param1", "params": { "param1": 50 } } } } new ScriptQuery { Name = "named_query", Boost = 1.1, Source = _templateString, Params = new Dictionary<string, object> { { "param1", 50 } } }