This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # update apt | |
| sudo apt-get update | |
| # install java | |
| sudo apt-get install openjdk-7-jre-headless -y | |
| # install elasticsearch | |
| wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.1.1.deb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Bringing machine 'default' up with 'virtualbox' provider... | |
| [default] Importing base box 'precise32'... | |
| ... | |
| [default] Machine booted and ready! | |
| ... | |
| Setting up openjdk-7-jre-headless (7u55-2.4.7-1ubuntu1~0.12.04.2) ... | |
| ... | |
| --2014-05-05 07:50:35-- https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.1.1.deb | |
| ... | |
| sudo /etc/init.d/elasticsearch start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace ConsoleApplication1 | |
| { | |
| public class Customer | |
| { | |
| public int Zipcode { get; set; } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var connectionSettings = new ConnectionSettings(new Uri("http://localhost:9200/")); | |
| connectionSettings.SetDefaultIndex("customers"); | |
| var elasticClient = new ElasticClient(connectionSettings); | |
| elasticClient.CreateIndex("customers-v1"); | |
| elasticClient.Alias(x => x.Add(a => a.Alias("customers").Index("customers-v1"))); | |
| elasticClient.Map<Customer>(d => | |
| d.Properties(p => p.Number(n => n.Name(name => name.Zipcode).Index(NonStringIndexOption.not_analyzed)))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| elasticClient.Index(new Customer { Zipcode = 8000 }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var reindex = | |
| elasticClient.Reindex<Customer>(r => | |
| r.FromIndex("customers-v1") | |
| .ToIndex("customers-v2") | |
| .Query(q => q.MatchAll()) | |
| .Scroll("10s") | |
| .CreateIndex(i => | |
| i.AddMapping<Customer>(m => | |
| m.Properties(p => | |
| p.String(n => n.Name(name => name.Zipcode).Index(FieldIndexOption.not_analyzed)))))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| elasticClient.DeleteIndex(d => d.Index("customers-v1")); | |
| elasticClient.Alias(x => x.Add(a => a.Alias("customers").Index("customers-v2"))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var result = elasticClient.Search<ErrorDocument>(search => search | |
| .SearchType(SearchType.Count) | |
| .Query(q => q | |
| .Range(range => range | |
| .OnField(field => field.Time) | |
| .GreaterOrEquals(DateTime.UtcNow.AddHours(-24)) | |
| .LowerOrEquals(DateTime.UtcNow) | |
| ) | |
| ) | |
| .Aggregations(a => a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |
| <PlatformTarget>AnyCPU</PlatformTarget> | |
| <DebugSymbols>true</DebugSymbols> | |
| <DebugType>full</DebugType> | |
| <Optimize>false</Optimize> | |
| <OutputPath>bin\Debug\</OutputPath> | |
| <DefineConstants>DEBUG;TRACE</DefineConstants> | |
| <ErrorReport>prompt</ErrorReport> | |
| <WarningLevel>4</WarningLevel> | |
| <LangVersion>Experimental</LangVersion> |