Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

OperationMethods Supported
Insert


Expand
titleInsert Methods Supported -Elasticsearch.Net
  • Elasticsearch.Net.ElasticLowLevelClient.Index
  • Elasticsearch.Net.ElasticLowLevelClient.IndexAsync


Expand
titleInsert Methods Supported - NEST
  • Nest.ElasticClient.Index
  • Nest.ElasticClient.IndexAsync
  • Nest.ElasticClient.IndexDocument
  • Nest.ElasticClient.IndexDocumentAsync


Update


Expand
titleUpdate Methods Supported - Elasticsearch.Net
  • Elasticsearch.Net.ElasticLowLevelClient.Update
  • Elasticsearch.Net.ElasticLowLevelClient.UpdateAsync
  • Elasticsearch.Net.ElasticLowLevelClient.UpdateByQuery
  • Elasticsearch.Net.ElasticLowLevelClient.UpdateByQueryAsync


Expand
titleUpdate Methods Supported - NEST
  • Nest.ElasticClient.Update
  • Nest.ElasticClient.UpdateAsync
  • Nest.ElasticClient.UpdateByQuery
  • Nest.ElasticClient.UpdateByQueryAsync


Select


Expand
titleSelect Methods Supported - Elasticsearch.Net
  • Elasticsearch.Net.ElasticLowLevelClient.Search
  • Elasticsearch.Net.ElasticLowLevelClient.SearchAsync
  • Elasticsearch.Net.ElasticLowLevelClient.DocumentExists
  • Elasticsearch.Net.ElasticLowLevelClient.DocumentExistsAsync
  • Elasticsearch.Net.ElasticLowLevelClient.Explain
  • Elasticsearch.Net.ElasticLowLevelClient.ExplainAsync


Expand
titleSelect Methods Supported - NEST
  • Nest.ElasticClient.Search
  • Nest.ElasticClient.SearchAsync
  • Nest.ElasticClient.DocumentExists
  • Nest.ElasticClient.DocumentExistsAsync
  • Nest.ElasticClient.Explain
  • Nest.ElasticClient.ExplainAsync
  • Nest.ElasticClient.Get
  • Nest.ElasticClient.GetAsync


Delete 


Expand
titleDelete Methods Supported - Elasticsearch.Net
  • Elasticsearch.Net.ElasticLowLevelClient.Delete
  • Elasticsearch.Net.ElasticLowLevelClient.DeleteAsync
  • Elasticsearch.Net.ElasticLowLevelClient.DeleteByQuery
  • Elasticsearch.Net.ElasticLowLevelClient.DeleteByQueryAsync


Expand
titleDelete Methods Supported - NEST
  • Nest.ElasticClient.Delete
  • Nest.ElasticClient.DeleteAsync
  • Nest.ElasticClient.DeleteByQuery
  • Nest.ElasticClient.DeleteByQueryAsync


Objects

Icon Description

DotNet Elasticsearch Cluster

DotNet Elasticsearch Index

DotNet Unknown Elasticsearch Index 

...

Once the analysis/snapshot generation has completed, you can view the results in the normal manner (for example via CAST Enlighten). Some examples are shown below.

Cluster Creation and Default Index(Elasticsearch.Net and NEST)

Code Block
languagec#
titleCluster Creation and Default Index
class HighLevel
{
        public void UsingConnectionPool()
        {            var uris = new[]
	             {
	                new Uri("http://localhost:9200"),
	                new Uri("http://localhost:9201"), 
	               new Uri("http://localhost:9202"), 
	             };
	            var connectionPool = new SniffingConnectionPool(uris);
	            var settings = new ConnectionSettings(connectionPool)
		                .DefaultIndex("people");
	            var client = new ElasticClient(settings);
        }
}



Insert Operation(Elasticsearch.Net and NEST)

Code Block
languagec#
titleIndexDocument
public void Indexing()
{
            var person = new Person
            {
                Id = 1,
                FirstName = "Martijn",
                LastName = "Laarman"
            };
            var ndexResponse = client.IndexDocument(person); //<1>
}

...

Code Block
languagec#
titleIndexDocumentAsync
public async Task IndexingAsync()
{            var person = new Person
            {
                Id = 2,
                FirstName = "Jack",
                LastName = "Mas" 
           };
           var asyncIndexResponse = await client.IndexDocumentAsync(person); 
}

Update Operation(Elasticsearch.Net and NEST)

Code Block
languagec#
titleUpdate
public static bool updateDocument(string searchID, string first_name, string last_name)
{
		bool status;
           	//Update by Partial Document
               var response = client.Update<DocumentAttributes, UpdateDocumentAttributes>(searchID, d => d
                .Index(index)
                .Doc(new UpdateDocumentAttributes
                {
                    FirstName = first_name,
                    LastName = last_name
                 }));            
}

Select

...

Operation(Elasticsearch.Net and NEST)

Code Block
languagec#
titleSelect
public void SearchingOnDefaultIndex()        
{
	var searchResponse = client.Search<Person>(s => s
                .From(0)
                .Size(10)
                .Query(q => q
                     .Match(m => m
                        .Field(f => f.FirstName)
                        .Query("Martijn")
                     )
                )
            );
            var people = searchResponse.Documents;        
}

Delete Operation(Elasticsearch.Net and NEST)

Code Block
languagec#
titleDelete
public static bool deleteDocument(string index, string searchID)        
{
		bool status;
            	var response = client.Delete<DocumentAttributes>(searchID, d => d
                	.Index(index));
		if (response.IsValid)
		{
	             status = true;
            	}
	       else
	       {
	                status = false;
               }
            return status;
}   

Evolution

  • Previously, only files consisting of relevant Elasticsearch imports were processed further for analysing.
  • Support has been evolved to process a file when it does not contain Elasticsearch import but makes use of its methods. Assumption is file is using same namespace as used in the file containing Elasticsearch imports.

Limitations

...

  • Index name is hardcoded
  • Index  name  is defined in the variable in the local method
  • Index  is defined as C# field
  • Index or default name information is present in .config file

...

Bulk Operations(Elasticsearch.Net and NEST)

Code Block
languagec#
titleBulkOperations
public void BulkOperations()        
{
            var people = new object[]
            {
                new { index = new { _index = "people", _type = "person", _id = "1"  }},
                new { FirstName = "Martijn", LastName = "Laarman" },
                new { index = new { _index = "people", _type = "person", _id = "2"  }},
                new { FirstName = "Greg", LastName = "Marzouka" },
                new { index = new { _index = "people", _type = "person", _id = "3"  }},
                new { FirstName = "Russ", LastName = "Cam" },
             };
            var ndexResponse = lowlevelClient.Bulk<StringResponse>(PostData.MultiJson(people));
            string responseStream = ndexResponse.Body;
}


Code Block
languagec#
titleBulk Operations Using Fluent DSL
public void BulkOperationsUsingFluentDSL ()
{
            var result = client.Bulk(b => b
            .Index<Person>(i => i
                .Document(new Person {Id = 2})
             )   
             .Create<Person>(c => c
                .Document(new Person { Id = 3 })
            )
            .Delete<Person>(d => d
                .Document(new Person { Id = 4 })
            ));
}

Image AddedImage Added

Evolution

  • Better evaluation of index and, cluster names
  • Support for additional APIs.

Limitations

  • If index names are not resolved, the links are created between methods and default or unknown index objects
  • Bulk operations using ObjectInitializerSyntax result in useLinks only
  • Version .NET SDK 6.x and 7.x are supported

Future development

  • Bulk operations to be scanned for the presence of insert (indexing) , update and delete operations
  • Resolving the index  name when passed as arguments in methodUnable to resolve Cluster and Index names from configuration files