diff --git a/.gitignore b/.gitignore index b0ee1b7f0c2..c7f519db787 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,9 @@ _ReSharper*/ _NCrunch*/ [Tt]est[Rr]esult* +keypair.snk +private.snk +*.snk build/keys/private.snk build/keys/keypair.snk build/* @@ -41,9 +44,15 @@ build/* build/tools/* !build/tools/sn !build/tools/ilmerge +!build/*.fsx +!build/*.fsx +!build/*.ps1 +!build/*.nuspec + /dep/Newtonsoft.Json.4.0.2 !new_docs/build new_docs/node_modules +doc/Help /src/Nest.Tests.Unit/*.ncrunchproject *.ncrunchproject diff --git a/build/Elasticsearch.Net.Connection.Thrift.nuspec b/build/Elasticsearch.Net.Connection.Thrift.nuspec new file mode 100644 index 00000000000..804945c28a3 --- /dev/null +++ b/build/Elasticsearch.Net.Connection.Thrift.nuspec @@ -0,0 +1,26 @@ + + + + Elasticsearch.Net.Connection.Thrift + 1.0.0-beta1 + Elasticsearch.Net.Connection.Thrift - Thrift support for Elasticsearch.Net + Martijn Laarman and contributors + Martijn Laarman + http://nest.azurewebsites.net/images/elasticsearch-net-nuget-icon.png + http://mpdreamz.mit-license.org/ + https://github.com/Mpdreamz/NEST + An IConnection implementation that utilizes Apache Thrift to talk with elasticsearch + false + An IConnection implementation that utilizes Apache Thrift to talk with elasticsearch + + + + + elasticsearch elastic search lucene thrift nest + + + + + + + \ No newline at end of file diff --git a/build/Elasticsearch.Net.nuspec b/build/Elasticsearch.Net.nuspec new file mode 100644 index 00000000000..c4050c440f3 --- /dev/null +++ b/build/Elasticsearch.Net.nuspec @@ -0,0 +1,25 @@ + + + + Elasticsearch.Net + 1.0.0-beta1 + Elasticsearch.Net - official low level elasticsearch client + Martijn Laarman and contributors + Martijn Laarman + http://nest.azurewebsites.net/images/elasticsearch-net-nuget-icon.png + http://mpdreamz.mit-license.org/ + https://github.com/elasticsearch/elasticsearch-net + Exposes all the api endpoints but leaves you in control of building the request and response bodies. Comes with built in cluster failover/connection pooling support. + + false + Exposes all the api endpoints but leaves you in control of building the request and response bodies. Comes with built in cluster failover/connection pooling support. + + elasticsearch elastic search lucene nest + + + + + + + + \ No newline at end of file diff --git a/build/InheritDoc.fsx b/build/InheritDoc.fsx new file mode 100644 index 00000000000..a9b1dc5a7ac --- /dev/null +++ b/build/InheritDoc.fsx @@ -0,0 +1,25 @@ +#r "System.Xml.Linq.dll" +open System.Xml +open System.Xml.XPath +open System.Linq +open System.Xml.Linq +open System.Text.RegularExpressions + +let PatchXmlDoc = fun (file: string) -> + let xml = XDocument.Load file + let nodes = xml.XPathSelectElements("//inheritdoc") + |> Seq.map (fun n -> + let methodName = n.Parent.Attribute(XName.Get("name")).Value + let interfaceName = Regex.Replace(methodName, @"\.([^.]+\.[^.]+\()", ".I$1") + let interfaceNode = xml.XPathSelectElement (sprintf "//member[@name='%s']" interfaceName) + (n.Parent, interfaceNode) + ) + |> Seq.filter (fun (implementationElement, interfaceElement) -> + interfaceElement <> null && implementationElement.HasElements && interfaceElement.HasElements + ) + let nodesReplace = nodes + |> Seq.iter (fun (implementationElement, interfaceElement) -> + implementationElement.Add (interfaceElement.Descendants().ToList()) + ) + + xml.Save file \ No newline at end of file diff --git a/build/NEST.nuspec b/build/NEST.nuspec index bdb654ec3af..1736801f9e2 100644 --- a/build/NEST.nuspec +++ b/build/NEST.nuspec @@ -2,7 +2,7 @@ NEST - 0.0.0.1 + 1.0.0-beta1 NEST - Elasticsearch Client Martijn Laarman and contributors Martijn Laarman @@ -13,7 +13,7 @@ false Elasticsearch client, strongly typed interface to Elasticsearch. Fluent request builder, mapped responses and powerful query dsl. Uses and exposes Elasticsearch.Net - + elasticsearch elastic search lucene nest @@ -22,5 +22,6 @@ + \ No newline at end of file diff --git a/build/build.fsx b/build/build.fsx index 364e5c2b669..4664c4aadf3 100644 --- a/build/build.fsx +++ b/build/build.fsx @@ -1,7 +1,12 @@ // include Fake lib #r @"tools/FAKE/tools/FakeLib.dll" +#load @"InheritDoc.fsx" open Fake open System +open InheritDoc +open SemVerHelper +open AssemblyInfoFile + // Properties let buildDir = "build/output/" @@ -14,11 +19,34 @@ Target "Clean" (fun _ -> CleanDir buildDir ) + + Target "BuildApp" (fun _ -> + let binDirs = !! "src/**/bin/**" + |> Seq.map DirectoryName + |> Seq.distinct + |> Seq.filter (fun f -> (f.EndsWith("Debug") || f.EndsWith("Release")) && not (f.Contains "CodeGeneration")) + + CleanDirs binDirs + + //Override the prebuild event because it just calls a fake task BuildApp depends on anyways + let msbuildProperties = [ + ("Configuration","Release"); + ("PreBuildEvent","ECHO"); + ] + //Compile each csproj and output it seperately in build/output/PROJECTNAME !! "src/**/*.csproj" |> Seq.map(fun f -> (f, buildDir + directoryInfo(f).Name.Replace(".csproj", ""))) - |> Seq.iter(fun (f,d) -> MSBuildRelease d "Build" (seq { yield f }) |> ignore) + |> Seq.iter(fun (f,d) -> MSBuild d "Build" msbuildProperties (seq { yield f }) |> ignore) + + //Scan for xml docs and patch them to replace with the documentation + //from their interfaces + !! "build/output/Nest/Nest.xml" |> Seq.iter(fun f -> PatchXmlDoc f) + + CopyFile "build/output/Nest/init.ps1" "build/nest-init.ps1" + CopyFile "build/output/Elasticsearch.Net/init.ps1" "build/elasticsearch-init.ps1" + ) Target "Test" (fun _ -> @@ -31,85 +59,130 @@ Target "Test" (fun _ -> ) let keyFile = "build/keys/keypair.snk" -let validateSignedAssembly = fun name -> + +let createKeys = fun _ -> let sn = "build/tools/sn/sn.exe" ExecProcess(fun p -> p.FileName <- sn - p.Arguments <- sprintf @"-v build\output\%s.dll" name - ) (TimeSpan.FromMinutes 5.0) - -let signAssembly = fun name -> - let ilmerge = "build/tools/ilmerge/ILMerge.exe" - let platform = @"/targetplatform:v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319" - let i = sprintf "build\\output\\%s\\%s" name name - let o = sprintf "build\\output\\%s" name + p.Arguments <- sprintf @"-k %s" keyFile + ) (TimeSpan.FromMinutes 5.0) |> ignore + + ExecProcess(fun p -> + p.FileName <- sn + p.Arguments <- sprintf @"-p %s %s" keyFile "build/keys/public.snk" + ) (TimeSpan.FromMinutes 5.0) |> ignore + +Target "CreateKeysIfAbsent" (fun _ -> + if not (fileExists keyFile) then createKeys() +) + +let validateSignedAssembly = fun name -> + let sn = "build/tools/sn/sn.exe" + let out = (ExecProcessAndReturnMessages(fun p -> + p.FileName <- sn + p.Arguments <- sprintf @"-v build\output\%s\%s.dll" name name + ) (TimeSpan.FromMinutes 5.0)) - let dll = i + ".dll" - let outdll = o + ".dll" - let pdb = o + ".pdb" - - let signExitCode = ( - ExecProcess(fun p -> - p.FileName <- ilmerge - p.Arguments <- (sprintf "%s /keyfile:%s /out:%s %s" - dll keyFile outdll platform) - ) (TimeSpan.FromMinutes 5.0) - ) + let valid = (out.ExitCode, out.Messages.FindIndex(fun s -> s.Contains("is valid"))) + + match valid with + | (0, i) when i >= 0 -> trace (sprintf "%s was signed correctly" name) + | (_, _) -> failwithf "{0} was not validly signed" + + let out = (ExecProcessAndReturnMessages(fun p -> + p.FileName <- sn + p.Arguments <- sprintf @"-T build\output\%s\%s.dll" name name + ) (TimeSpan.FromMinutes 5.0)) + + let tokenMessage = (out.Messages.Find(fun s -> s.Contains("Public key token is"))); + let token = (tokenMessage.Replace("Public key token is", "")).Trim(); - let validateExitCode = validateSignedAssembly name - match (signExitCode, validateExitCode) with - | (0,0) -> - MoveFile (DirectoryName dll) outdll - MoveFile (DirectoryName dll) pdb - | _ -> - failwithf "Failed to sign {0}" name + let valid = (out.ExitCode, token) + let oficialToken = "96c599bbe3e70f5d" + match valid with + | (0, t) when t = oficialToken -> + trace (sprintf "%s was signed with official key token %s" name t) + | (_, t) -> traceFAKE "%s was not signed with the official token: %s but %s" name oficialToken t let nugetPack = fun name -> - + let fileVersion = (getBuildParamOrDefault "version" "0.1.0") CreateDir nugetOutDir - + let package = (sprintf @"build\%s.nuspec" name) + let packageContents = ReadFileAsString package + let re = @"(?\|""(Elasticsearch.Net|Nest)"" version="")[^""><]+(?\<\/version\>|"")" + let replacedContents = regex_replace re (sprintf "${start}%s${end}" fileVersion) packageContents + WriteStringToFile false package replacedContents + let dir = sprintf "%s/%s/" buildDir name - let version = "1.0.0-c2" NuGetPack (fun p -> {p with - Version = version + Version = fileVersion WorkingDir = dir OutputPath = dir }) - (sprintf @"build\%s.nuspec" name) + package - MoveFile nugetOutDir (buildDir + (sprintf "%s/%s.%s.nupkg" name name version)) + MoveFile nugetOutDir (buildDir + (sprintf "%s/%s.%s.nupkg" name name fileVersion)) let buildDocs = fun action -> let node = @"build\tools\Node.js\node.exe" let wintersmith = @"..\build\tools\node_modules\wintersmith\bin\wintersmith" ExecProcess (fun p -> - p.WorkingDirectory <- "new_docs" - p.FileName <- node - p.Arguments <- sprintf "\"%s\" %s" wintersmith action - ) (TimeSpan.FromMinutes (if action = "preview" then 300.0 else 5.0)) - + p.WorkingDirectory <- "new_docs" + p.FileName <- node + p.Arguments <- sprintf "\"%s\" %s" wintersmith action + ) + (TimeSpan.FromMinutes (if action = "preview" then 300.0 else 5.0)) + Target "Version" (fun _ -> - let v = (getBuildParamOrDefault "version" "0.1.0") - let version = SemVerHelper.parse v - let assemblyVersion = sprintf "%i.%i.0.0" version.Major version.Minor - - trace (sprintf "%s %s" v assemblyVersion) - + let fileVersion = (getBuildParamOrDefault "version" "0.1.0") + let version = SemVerHelper.parse fileVersion + + let suffix = fun (prerelease: PreRelease) -> sprintf "-%s%i" prerelease.Name prerelease.Number.Value + let assemblySuffix = if version.PreRelease.IsSome then suffix version.PreRelease.Value else ""; + let assemblyVersion = sprintf "%i.0.0%s" version.Major assemblySuffix + + match (assemblySuffix, version.Minor, version.Patch) with + | (s, m, p) when s <> "" && (m <> 0 || p <> 0) -> failwithf "Cannot create prereleases for minor or major builds!" + | ("", _, _) -> traceFAKE "Building fileversion %s for asssembly version %s" fileVersion assemblyVersion + | _ -> traceFAKE "Building prerelease %s for major assembly version %s " fileVersion assemblyVersion + + let assemblyDescription = fun (f: string) -> + let name = f + match f.ToLowerInvariant() with + | f when f = "elasticsearch.net" -> "Elasticsearch.Net - oficial low level elasticsearch client" + | f when f = "nest" -> "NEST - oficial high level elasticsearch client" + | f when f = "elasticsearch.net.connection.thrift" -> "Elasticsearc.Net.Connection.Thrift - Add thrift support to elasticsearch." + | _ -> sprintf "%s" name + + !! "src/**/AssemblyInfo.cs" + |> Seq.iter(fun f -> + let name = (directoryInfo f).Parent.Parent.Name + CreateCSharpAssemblyInfo f [ + Attribute.Title name + Attribute.Copyright (sprintf "Elasticsearch %i" DateTime.UtcNow.Year) + Attribute.Description (assemblyDescription name) + Attribute.Company "Elasticsearch" + Attribute.Configuration "Release" + Attribute.Version assemblyVersion + Attribute.FileVersion fileVersion + Attribute.InformationalVersion fileVersion + ] + ) ) + Target "Release" (fun _ -> if not <| fileExists keyFile then failwithf "{0} does not exist to sign the assemblies" keyFile - //signAssembly("Elasticsearch.Net") - //signAssembly("Elasticsearch.Net.Connection.Thrift") - //signAssembly("Nest") - nugetPack("Elasticsearch.Net") nugetPack("Elasticsearch.Net.Connection.Thrift") nugetPack("Nest") + validateSignedAssembly("Elasticsearch.Net") + validateSignedAssembly("Elasticsearch.Net.Connection.Thrift") + validateSignedAssembly("Nest") ) Target "Docs" (fun _ -> buildDocs "build" |> ignore) @@ -120,14 +193,19 @@ Target "DocsPreview" (fun _ -> // Dependencies "Clean" + ==> "CreateKeysIfAbsent" + =?> ("Version", hasBuildParam "version") ==> "BuildApp" ==> "Test" ==> "Build" "Build" + ==> "Docs" ==> "Release" "DocsPreview" +"BuildApp" +"CreateKeysIfAbsent" "Version" // start build RunTargetOrDefault "Build" \ No newline at end of file diff --git a/build/elasticsearch-init.ps1 b/build/elasticsearch-init.ps1 new file mode 100644 index 00000000000..c73464ac655 --- /dev/null +++ b/build/elasticsearch-init.ps1 @@ -0,0 +1 @@ +$DTE.ItemOperations.Navigate("http://nest.azurewebsites.net/elasticsearch-net/quick-start.html") \ No newline at end of file diff --git a/build/keys/public.snk b/build/keys/public.snk deleted file mode 100644 index 9c2e41d4a64..00000000000 Binary files a/build/keys/public.snk and /dev/null differ diff --git a/build/nest-init.ps1 b/build/nest-init.ps1 new file mode 100644 index 00000000000..ebeee869b83 --- /dev/null +++ b/build/nest-init.ps1 @@ -0,0 +1 @@ +$DTE.ItemOperations.Navigate("http://nest.azurewebsites.net/nest/quick-start.html") \ No newline at end of file diff --git a/doc/Help/Documentation.chm b/doc/Help/Documentation.chm deleted file mode 100644 index b31a34515db..00000000000 Binary files a/doc/Help/Documentation.chm and /dev/null differ diff --git a/doc/documentation.shfbproj b/doc/documentation.shfbproj deleted file mode 100644 index 09f798bfa0a..00000000000 --- a/doc/documentation.shfbproj +++ /dev/null @@ -1,58 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - {0e1c3ab9-9af2-41dc-af01-e99f4c71f588} - 1.9.9.0 - - Documentation - Documentation - Documentation - - .NET Framework 4.0 - .\Help\ - Documentation - en-US - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ..\src\Nest\bin\Release\Nest.dll - - - - - \ No newline at end of file diff --git a/doc/ghostdoc.gdc b/doc/ghostdoc.gdc deleted file mode 100644 index 76f2e692c74..00000000000 Binary files a/doc/ghostdoc.gdc and /dev/null differ diff --git a/new_docs/build/elasticsearch-net/building-requests.html b/new_docs/build/elasticsearch-net/building-requests.html index 40dc40c9fb2..9f8e7ea929c 100644 --- a/new_docs/build/elasticsearch-net/building-requests.html +++ b/new_docs/build/elasticsearch-net/building-requests.html @@ -1,5 +1,5 @@ Nest - Building Requests

Elasticsearch.Net

Documentation

Building Requests

-

This section decribes how to build requests to elasticsearch.

+

This section decribes how to build requests to Elasticsearch.

Calling an API endpoint

Elasticsearch.Net maps all the Elasticsearch API endpoints to methods. The reason it can do this is because all these methods are generated from the official client rest specification. This specification documents all diff --git a/new_docs/build/elasticsearch-net/cluster-failover.html b/new_docs/build/elasticsearch-net/cluster-failover.html index 27ee0cf586d..b4d2ad46d0e 100644 --- a/new_docs/build/elasticsearch-net/cluster-failover.html +++ b/new_docs/build/elasticsearch-net/cluster-failover.html @@ -1,5 +1,5 @@ Nest - Cluster Failover

Elasticsearch.Net

Documentation

Connection pooling & Cluster failover

-

One of the major benefits of elasticsearch is that it can handle dying and respawning nodes. +

One of the major benefits of Elasticsearch is that it can handle dying and respawning nodes. As long as enough nodes agree that the cluster is healthy, the cluster will continue to operate. Elasticsearch.net comes with builtin support to handle falling over to a different node when the requested node failed.

Configuring

@@ -21,7 +21,7 @@

SetDeadTimeout()

SetMaxDeadTimeout()

Sets the maximum time a node may be marked dead.

DisablePings()

-

By default before a previously dead node is retried a short ping will be send to the node to make sure the node will respond. +

By default before a previously dead node is retried a short ping will be sent to the node to make sure the node will respond. The reason for a separate call is that a ping will call an elasticsearch endpoint that won't stress the JVM. If a node is having issues retrying a possible heavy search operation on it might cause the request to fail later rather then asap. This setting allows you to disable these pings before retries.

SetMaxRetries(int retries)

By default an IConnectionPool itself will decide how many times to retry (usually all the registered nodes) if you wish to diff --git a/new_docs/build/elasticsearch-net/errors.html b/new_docs/build/elasticsearch-net/errors.html index d4759c45073..786ced35b11 100644 --- a/new_docs/build/elasticsearch-net/errors.html +++ b/new_docs/build/elasticsearch-net/errors.html @@ -1,5 +1,5 @@ Nest - Quick Start

Elasticsearch.Net

Documentation

Errors

-

Elasticsearch.Net will not throw if gets a http response other then 200 from Elasticsearch. The response object's Success property will be false and .Error will contain information on the failed response.

+

Elasticsearch.Net will not throw if it gets an http response other then 200 from Elasticsearch. The response object's Success property will be false and .Error will contain information on the failed response.

You can throw custom exceptions if you need too by specifying a custom connectionhandler

var settings = new ConnectionConfiguration()
     .SetConnectionStatusHandler(r=> {
@@ -7,6 +7,6 @@
            throw new MyApplicationNotLoggedInException();
         });
 

Exceptions

-

If a request has been retried the maximum amount of times a MaxRetryException is thrown. Note that requests are only retried when elasticsearch responds with a 503 or an unspecified connection exception (i.e timeout) occured on a node.

+

If a request has been retried the maximum amount of times a MaxRetryException is thrown. Note that requests are only retried when elasticsearch responds with a 503 or an unspecified connection exception (i.e timeout) has occured on a node.

MaxRetryException will hold the original exception as .InnerException.

\ No newline at end of file diff --git a/new_docs/build/elasticsearch-net/quick-start.html b/new_docs/build/elasticsearch-net/quick-start.html index ddd4c9f31ba..95bdc58ddf1 100644 --- a/new_docs/build/elasticsearch-net/quick-start.html +++ b/new_docs/build/elasticsearch-net/quick-start.html @@ -1,5 +1,5 @@ Nest - Quick Start

Elasticsearch.Net

Documentation

Quick Start

-

Elasticsearch.Net is a low level client to talk to elasticsearch.

+

Elasticsearch.Net is a low level client to talk to Elasticsearch.

Installing

From the package manager console inside visual studio

PM > Install Package Elasticsearch.Net -PreRelease
diff --git a/new_docs/build/index.html b/new_docs/build/index.html
index 3b6340b21de..750cfd77263 100644
--- a/new_docs/build/index.html
+++ b/new_docs/build/index.html
@@ -1,5 +1,5 @@
 Nest - Introduction

Elasticsearch.Net & NEST

Documentation

Introduction

-

You've reached the documentation page for Elasticsearch.Net and NEST. Two .net clients to talk with elasticsearch. So why two clients I hear you say?

+

You've reached the documentation page for Elasticsearch.Net and NEST. Two .net clients to talk with Elasticsearch. So why two clients I hear you say?

Elasticsearch.Net is a very low level, dependency free, client that has no opinions how you build and represent your requests and responses. It has abstracted enough so that all the elasticsearch API endpoints are represented as methods but not too much to get in the way of how you want to build your json/request/response objects. It also comes with builtin, configurable/overridable, cluster failover retry mechanisms. Elasticsearch is elastic so why not your client?

NEST is a high level client that has the advantage of having mapped all the request and response objects, comes with a strongly typed query DSL that maps 1 to 1 with the elasitcsearch query dsl and takes advantage of specific .net features such as covariant results. NEST internally uses, and still exposes, the low level Elasticsearch.Net client

@@ -8,9 +8,9 @@

Who's using Nest

Other resources

@joelabrahamsson wrote a great intro into elasticsearch on .NET diff --git a/new_docs/build/nest/cluster/health.html b/new_docs/build/nest/cluster/health.html index bd6c0e88fe7..3cf88afa661 100644 --- a/new_docs/build/nest/cluster/health.html +++ b/new_docs/build/nest/cluster/health.html @@ -1,7 +1,7 @@ Nest - Connecting

NEST

Documentation

Health

Get cluster health simple

var r = this._client.Health(HealthLevel.Cluster);
-

Cluster health just for one (or more) index

+

Cluster health for one (or more) indexes

var r = this._client.Health(new[] { Test.Default.DefaultIndex }, HealthLevel.Cluster);
 

Advanced options are mapped as well

var r = this._client.Health(new HealthParams
diff --git a/new_docs/build/nest/cluster/nodes-stats.html b/new_docs/build/nest/cluster/nodes-stats.html
index 47ea1939f32..0bbd35d54f4 100644
--- a/new_docs/build/nest/cluster/nodes-stats.html
+++ b/new_docs/build/nest/cluster/nodes-stats.html
@@ -1,6 +1,6 @@
 Nest - Connecting

NEST

Documentation

Nodes stats

var r = this._client.NodeInfo(NodesInfo.All);

        var node = r.Nodes.First();
-

you can than traverse the node info objects i.e:

+

You can than traverse the node info objects i.e:

        node.Value.OS.Cpu.CacheSizeInBytes;
 
\ No newline at end of file diff --git a/new_docs/build/nest/connecting.html b/new_docs/build/nest/connecting.html index 3a4d9a47829..39e1c94162f 100644 --- a/new_docs/build/nest/connecting.html +++ b/new_docs/build/nest/connecting.html @@ -11,10 +11,10 @@

Choosing the right connection st for calls which do not explicitly state an index name. Specifying a default index is optional but very handy.

If you want a failover client instead of passing a Uri pass an IConnectionPool see the Elasticsearch.Net documentation on cluster failover all of its implementations can also be used with NEST.

Changing the underlying connection

-

By default NEST will use HTTP to chat with elasticsearch, alternative implementation of the transport layer can be injected in the constructors optional second parameter

+

By default NEST will use HTTP to chat with elasticsearch, alternative implementation of the transport layer can be injected using the constructors optional second parameter

var client = new ElasticClient(settings, new ThriftConnection(settings));
-

Nest comes with a Htpp connection HttpConnection, Thrift Connection ThriftConnection -and an in memory connection that nevers hits elasticsearch InMemoryConnection.

+

NEST comes with an Http Connection HttpConnection, Thrift Connection ThriftConnection +and an In-Memory Connection InMemoryConnection, that nevers hits elasticsearch.

Settings

The NEST client can be configured by passing in an IConnectionSettingsValues object, this interface is a subclass of Elasticsearch.Net's IConnectionConfigurationValues so all the settings that can be used to @@ -24,8 +24,8 @@

Settings

var settings = new ConnectionSettings(myConnectionPool, defaultIndex: "my-application")
     .PluralizeTypeNames();
 

AddContractJsonConverters

-

Add a custom JsonConverter to the build in json serialization by passing -in a predicate for a type. This way they will be part of the cached Json.net contract for a type.

+

Add a custom JsonConverter to the built in JSON serialization by passing +in a predicate for a type. This way they will be part of the cached Json.NET contract for a type.

settings.AddContractJsonConverters(t => 
     typeof (Enum).IsAssignableFrom(t) 
         ? new StringEnumConverter() 
@@ -42,13 +42,13 @@ 

SetDefaultIndex

SetDefaultPropertyNameInferrer

By default NEST camelCases property names (EmailAddress => emailAddress) that do not have an explicit propertyname either via an ElasticProperty attribute -or because they are part of Dictionary where the keys should be treated verbatim. +or because they are part of a Dictionary where the keys should be treated verbatim. Here you can register a function that transforms propertynames (default casing, pre- or suffixing)

SetDefaultTypeNameInferrer

-

Allows you to override how type names should be reprented, the default will +

Allows you to override how type names should be represented, the default will call .ToLowerInvariant() on the type's name.

SetJsonSerializerSettingsModifier

-

Allows you to update internal the json.net serializer settings to your liking. -Do not use this to add custom json converters use AddContractJsonConverters instead.

+

Allows you to update the internal Json.NET Serializer settings to your liking. +Do not use this to add custom JSON converters use AddContractJsonConverters instead.

\ No newline at end of file diff --git a/new_docs/build/nest/core/bulk.html b/new_docs/build/nest/core/bulk.html index 0f1aed34dc9..9889aca9006 100644 --- a/new_docs/build/nest/core/bulk.html +++ b/new_docs/build/nest/core/bulk.html @@ -1,12 +1,12 @@ Nest - Connecting

NEST

Documentation

Bulk

-

Nest long supported bulk index and deletes (through IndexMany() and DeleteMany()) but this shielded you from all that the elasticsearch _bulk api enpoint has to offer. Now you can use Bulk() to create any bulk request you'd like. E.g if you want to do index/create/delete's in a certain order.

+

NEST long supported bulk index and deletes (through IndexMany() and DeleteMany()) but this shielded you from all that the Elasticsearch _bulk api enpoint has to offer. Now you can use Bulk() to create any bulk request you'd like. E.g if you want to do index/create/delete's in a certain order.

Examples

var result = this._client.Bulk(b => b
     .Index<ElasticSearchProject>(i => i.Object(new ElasticSearchProject {Id = 2}))
     .Create<ElasticSearchProject>(i => i.Object(new ElasticSearchProject { Id = 3 }))
     .Delete<ElasticSearchProject>(i => i.Object(new ElasticSearchProject { Id = 4 }))
 );
-

Each bulk operation can also be anotated with the right behaviours:

+

Each bulk operation can also be annotated with the right behaviours:

.Index<ElasticSearchProject>(i => i
     .Routing(...)
     .Refresh(...)
diff --git a/new_docs/build/nest/core/count.html b/new_docs/build/nest/core/count.html
index d0a094a6863..cd81861070c 100644
--- a/new_docs/build/nest/core/count.html
+++ b/new_docs/build/nest/core/count.html
@@ -2,7 +2,7 @@
 

The count API allows to easily execute a query and get the number of matches for that query. It can be executed across one or more indices and across one or more types. The query can either be provided using a simple query string as a parameter, or using the Query DSL defined within the request body. Here is an example:

var countResults = this._client.CountAll(q=>q.MatchAll());
 Assert.True(countResults.Count > 0);
-

The above will do a count query across all indices. (The result type here is not)

+

The above will do a count query across all indices. (The result type here is not limited)

If you want to limit the scope to just the default index for the type:

var countResults = this._client.Count<ElasticSearchProject>(q=>q.MatchAll());
 

This does a match all count query on the default index for ElasticSearchProject, if you need to specify custom indices use:

diff --git a/new_docs/build/nest/core/delete-by-query.html b/new_docs/build/nest/core/delete-by-query.html index bbb294de83f..3f72cf1fc53 100644 --- a/new_docs/build/nest/core/delete-by-query.html +++ b/new_docs/build/nest/core/delete-by-query.html @@ -6,7 +6,7 @@ .Term(f => f.Name, "elasticsearch.pm") );

As always *Async variants are available too.

-

You can also delete by query over all the indexes and types:

+

You can also delete by query over all the indices and types:

this.ConnectedClient.DeleteByQuery<ElasticSearchProject>(q => q
     .AllIndices()
     .Term(f => f.Name, "elasticsearch.pm")
diff --git a/new_docs/build/nest/core/get.html b/new_docs/build/nest/core/get.html
index a2e33a98621..17d3df89a10 100644
--- a/new_docs/build/nest/core/get.html
+++ b/new_docs/build/nest/core/get.html
@@ -1,12 +1,12 @@
 Nest - Connecting

NEST

Documentation

Get a document

-

gets a single document from Elasticsearch

+

Gets a single document from Elasticsearch

By Id

var foundDocument = this.ConnectedClient.Get<ElasticSearchProject>(hit.Id);
-

index and type are infered but overloads exists for full control

+

Index and type are infered but overloads exists for full control

var foundDocument = this.ConnectedClient.Get<ElasticSearchProject>("myalternateindex", "elasticprojs", hit.Id);
 

Full response

-

The Get<T>() call immediatly returns T which is handy in alot of cases but sometimes you'll want to get the complete metadata object back from Elasticsearch -using GetFull() you get a proper IGetResponse<T> back that holds the usual IsValid and ConnectionStatus properties amongst the Index, Type, Id and Version properties.

+

The Get<T>() call immediatly returns T which is handy in alot of cases but sometimes you'll want to get the complete metadata object back from Elasticsearch. +Using GetFull() you get a proper IGetResponse<T> back that holds the usual IsValid and ConnectionStatus properties amongst the Index, Type, Id and Version properties.

var result = this._client.GetFull<ElasticSearchProject>(g => g
     .Index("nest_test_data")
     .Type("elasticsearchprojects")
@@ -18,17 +18,17 @@ 

By Id

.Id(1) );

Follows the same inferring rules as .Get(id) would.

-

Infact you could even just pass an object:

+

In fact you could even just pass an object:

var result = this._client.GetFull<SomeDto>(g => g
     .Object(new SomeDto { AlternateId = Guid.NewGuid() })
 );
-

provided SomeDto is mapped properly to use AlternateId as the alternate id field

+

Provided SomeDto is mapped properly to use AlternateId as the alternate id field.

[ElasticType(IdProperty = "AlternateId")]
 internal class SomeDto
 {
     public Guid AlternateId { get; set; }
 }
-

You can also use GetFull to query just some fields of a single document

+

You can also use GetFull to query just some fields of a single document

var result = this._client.GetFull<ElasticSearchProject>(g => g
     .Index("nest_test_data")
     .Type("elasticsearchprojects")
@@ -39,5 +39,5 @@ 

By Id

var name = result.Fields.FieldValue<string>(p => p.Name);
 var id = result.Fields.FieldValue<int>(p => p.Id);
 var doubleValue = result.Fields.FieldValue<double>(p => p.DoubleValue);
-

Remember p => p.Name can also be written as "name" and Nest does not force you to write expressions everywhere (although it is much encouraged!).

+

Remember p => p.Name can also be written as "name" and NEST does not force you to write expressions everywhere (although it is much encouraged!).

\ No newline at end of file diff --git a/new_docs/build/nest/core/index.html b/new_docs/build/nest/core/index.html index 84b51e0dd35..0c23b8ef986 100644 --- a/new_docs/build/nest/core/index.html +++ b/new_docs/build/nest/core/index.html @@ -2,10 +2,10 @@

Indexing is as simple as:

var post = new Post() { Id = 12, ... }
 var status = client.Index<Post>(post);
-

of course C# is smart enough to infer Post so

+

Of course C# is smart enough to infer Post so

var status = client.Index(post);
 

is sufficient. this will index post too /[default index]/posts/12. The typenameposts is automatically inferred from the type.

-

if you need more control there are plenty of overloads, i.e:

+

If you need more control there are plenty of overloads, i.e:

client.Index(post, "index", "type", "id");
 

Asynchronous

Indexing asynchronously is as easy as:

@@ -20,11 +20,11 @@

Instead of passing T just pass an IEnumerable<T> to IndexMany() or IndexManyAsync().

Note For asynchronous commands there's a special connection setting which automatically semaphores threaded communication -to ES for you:

+to Elasticsearch for you:

var elasticSettings = new ConnectionSettings("127.0.0.1.", 9200)
                           .SetDefaultIndex("mpdreamz")
                           .SetMaximumAsyncConnections(20);
-

this ensures that at most there are 20 asynchronous connections to ES others are enqueued until a slot is +

This ensures that at most there are 20 asynchronous connections to Elasticsearch. All others are enqueued until a slot is available.

Aditional parameters

Like the overloads just taking a T the IEnumerable<T> has alot of overloads taking in extra parameters.

diff --git a/new_docs/build/nest/core/multi-get.html b/new_docs/build/nest/core/multi-get.html index 5139f5db24a..37a6ad8bb46 100644 --- a/new_docs/build/nest/core/multi-get.html +++ b/new_docs/build/nest/core/multi-get.html @@ -3,7 +3,7 @@

Examples

var ids = new [] { hit1.Id, hit2.Id };
 var foundDocuments = this.ConnectedClient.MultiGet<ElasticSearchProject>(ids);
-

index and type are infered but overloads exists for full control

+

Index and type are infered but overloads exists for full control.

var foundDocuments = this.ConnectedClient.MultiGet<ElasticSearchProject>("myalternateindex", "elasticprojs", ids);
 

Multi Get Full

The previous calls are handy if you need to get many objects of a single type and don't care about the response or the metadata of the documents. If you do, NEST has you covered as well.

@@ -17,7 +17,7 @@

Examples

var person = result.Get<Person>(100000);
 var personHit = result.GetWithMetaData<Person>(100000);
 

Get returns T and GetWithMetaData returns a MultiGetHit<T> which also exposes the document's metadata such as _index and _version.

-

Incase the document was not found then Get would return a null but GetWithMetaData still returns the a MultiGetHit<T> but with an .Exists of false this maps to the way elasticsearch returns not found objects in a multi_get call.

+

In case the document was not found then Get would return a null but GetWithMetaData still returns the a MultiGetHit<T> but with an .Exists of false this maps to the way elasticsearch returns not found objects in a multi_get call.

You can even get field selections for some of the documents:

var result = this._client.MultiGetFull(a => a
     .Get<ElasticSearchProject>(g => g.
@@ -36,5 +36,5 @@ 

Examples

var fields = result.GetFieldSelection<ElasticSearchProject>(1);
 var id = fields.FieldValue<int>(p => p.Id);
 var firstNames = fields.FieldValue<string[]>(p => p.Followers.First().FirstName);
-

Remember p => p.Followers.First().FirstName can be interchanged with "followers.firstName" if you prefer or need to reference a non mapped field.

+

Remember p => p.Followers.First().FirstName can be interchanged with "followers.firstName" if you prefer or need to reference a non-mapped field.

\ No newline at end of file diff --git a/new_docs/build/nest/core/percolate.html b/new_docs/build/nest/core/percolate.html index 227e7c5235d..b12a0961efc 100644 --- a/new_docs/build/nest/core/percolate.html +++ b/new_docs/build/nest/core/percolate.html @@ -1,6 +1,6 @@ Nest - Connecting

NEST

Documentation

Percolation

The percolator allows to register queries against an index, and then send percolate requests which include a doc, and getting back the queries that match on that doc out of the set of registered queries.

-

The percolate is a complex but awesome elasticsearch feature be sure to read the official documentation

+

Percolate is a complex but awesome Elasticsearch feature, so be sure to read the official documentation

Register a percolator

var r = c.RegisterPercolator<ElasticSearchProject>(p => p
     .Name(name)
diff --git a/new_docs/build/nest/core/search.html b/new_docs/build/nest/core/search.html
index 78d8f131f5e..2cbd24eb1b8 100644
--- a/new_docs/build/nest/core/search.html
+++ b/new_docs/build/nest/core/search.html
@@ -1,5 +1,5 @@
 Nest - Connecting

NEST

Documentation

Search

-

Search is THE call you'll probably use the most as it exposes elasticsearch's key functionality: search!

+

Search is THE call you'll probably use the most as it exposes Elasticsearch's key functionality: search!

NOTE: be sure to also read how to use NEST's Query DSL

You can start a search like so,

var result = this._client.Search(s => s
@@ -9,7 +9,7 @@
      .Filter(f=> ....)         
 );
 

This will get all the documents on the my-index index and my-type type.

-

result is an IQueryResponse<dynamic> which has a Documents IEnumerable<dynamic> property that holds all the results. NOTE: remember in the absent of paging it will default to the first 10).

+

result is an IQueryResponse<dynamic> which has a Documents IEnumerable<dynamic> property that holds all the results. NOTE: remember in the absense of paging it will default to the first 10).

Typed results

Dynamic may or may not be what you want but in general it pays to type your search responses. In alot of cases you already need to have the POCO classes for indexing anyway.

var result = this._client.Search<ElasticSearchProject>(s => s
diff --git a/new_docs/build/nest/facets/date-histogram.html b/new_docs/build/nest/facets/date-histogram.html
index 2d1c356eb81..4f73fc042ba 100644
--- a/new_docs/build/nest/facets/date-histogram.html
+++ b/new_docs/build/nest/facets/date-histogram.html
@@ -10,5 +10,5 @@
     .Factor(1000)
   )
 );
-

See original docs for more information

+

See original docs for more information.

\ No newline at end of file diff --git a/new_docs/build/nest/facets/filter.html b/new_docs/build/nest/facets/filter.html index 39a8fe03cf2..8466a8cbdd5 100644 --- a/new_docs/build/nest/facets/filter.html +++ b/new_docs/build/nest/facets/filter.html @@ -8,5 +8,5 @@ .Exists(f=>f.Name) ) ); -

See original docs for more information

+

See original docs for more information.

\ No newline at end of file diff --git a/new_docs/build/nest/facets/geo-distance.html b/new_docs/build/nest/facets/geo-distance.html index 4e74e0a3484..3a5198b9fea 100644 --- a/new_docs/build/nest/facets/geo-distance.html +++ b/new_docs/build/nest/facets/geo-distance.html @@ -15,5 +15,5 @@ ) ) ); -

See original docs for more information

+

See original docs for more information.

\ No newline at end of file diff --git a/new_docs/build/nest/facets/handling.html b/new_docs/build/nest/facets/handling.html index 88d0ceba28c..eccab20c598 100644 --- a/new_docs/build/nest/facets/handling.html +++ b/new_docs/build/nest/facets/handling.html @@ -25,7 +25,7 @@

Specify facets during search.

.Size(20) ) ); -

Nest supports all the additional properties you can set on facets

+

NEST supports all the additional properties you can set on facets

var queryResults = this.ConnectedClient.Search<ElasticSearchProject>(s=>s
     .From(0)
     .Size(10)
@@ -46,12 +46,12 @@ 

Specify facets during search.

.TimeZones(Pre: "-3", Post: "-4") ) ); -

Allowing you to take advantage of all the cool facets stuff built in to elasticsearch.

+

Allowing you to take advantage of all the cool facets stuff built into Elasticsearch.

Getting to your facet

If you are interested in the facet meta data (such as missing, total) you can use the following methods:

var facet = queryResults.Facet<TermFacet>(p=>p.Followers.Select(f=>f.LastName));
-

this will return a TermFacet object which has an .Items property holding all the facets.

-

queryResult also holds a .Facets dictionary one can use to itterate over the facets returned from the query.

+

This will return a TermFacet object which has an .Items property holding all the facets.

+

queryResult also holds a .Facets dictionary one can use to iterate over the facets returned from the query.

Shortcut to facet items

To get the facet items for followers.lastName the prettiest way to get them is.

var facets = queryResults.FacetItems<FacetItem>(p=>p.Followers.Select(f=>f.LastName));
@@ -69,5 +69,5 @@ 

Corresponding Types

geo_distance => GeoDistanceFacet

query => QueryFacet

filter => FilterFacet

-

See also each individual facet's documentation

+

See also each individual facet's documentation.

\ No newline at end of file diff --git a/new_docs/build/nest/facets/histogram.html b/new_docs/build/nest/facets/histogram.html index 864ebb65e20..99c12ded002 100644 --- a/new_docs/build/nest/facets/histogram.html +++ b/new_docs/build/nest/facets/histogram.html @@ -6,5 +6,5 @@ .MatchAll() .FacetHistogram(h => h.OnField(f=>f.LOC).Interval(100)) ); -

See original docs for more information

+

See original docs for more information.

\ No newline at end of file diff --git a/new_docs/build/nest/facets/query.html b/new_docs/build/nest/facets/query.html index 1b1e1c1c2bd..099c5cb7a34 100644 --- a/new_docs/build/nest/facets/query.html +++ b/new_docs/build/nest/facets/query.html @@ -8,5 +8,5 @@ .Term(f=>f.Name, "elasticsearch.pm") ); ); -

See original docs for more information

+

See original docs for more information.

\ No newline at end of file diff --git a/new_docs/build/nest/facets/range.html b/new_docs/build/nest/facets/range.html index a022ba27d09..0e306a62815 100644 --- a/new_docs/build/nest/facets/range.html +++ b/new_docs/build/nest/facets/range.html @@ -1,5 +1,5 @@ Nest - Connecting

NEST

Documentation

Range Facet

-

range facet allow to specify a set of ranges and get both the number of docs (count) that fall within each range, and aggregated data either based on the field, or using another field. Here is a simple example:

+

Range faceting allows you to specify a set of ranges and get both the number of docs (count) that fall within each range, and aggregated data either based on the field, or using another field. Here is a simple example:

this.ConnectedClient.Search<ElasticSearchProject>(s=>s
     .From(0)
     .Size(10)
@@ -56,5 +56,5 @@
     )
 );
 //SNIP
-

See original docs for more information

+

See original docs for more information.

\ No newline at end of file diff --git a/new_docs/build/nest/facets/statistical.html b/new_docs/build/nest/facets/statistical.html index 32157a65048..106101b4840 100644 --- a/new_docs/build/nest/facets/statistical.html +++ b/new_docs/build/nest/facets/statistical.html @@ -1,5 +1,5 @@ Nest - Connecting

NEST

Documentation

Statistical Facet

-

Statistical facet allows to compute statistical data on a numeric fields. The statistical data include count, total, sum of squares, mean (average), minimum, maximum, variance, and standard deviation. Here is an example:

+

Statistical faceting allows you to compute statistical data on numeric fields. The statistical data includes count, total, sum of squares, mean (average), minimum, maximum, variance, and standard deviation. Here is an example:

this.ConnectedClient.Search<ElasticSearchProject>(s=>s
     .From(0)
     .Size(10)
@@ -8,5 +8,5 @@
         .OnField(f=>f.LOC)
     )
 );
-

See original docs for more information

+

See original docs for more information.

\ No newline at end of file diff --git a/new_docs/build/nest/facets/term-stats.html b/new_docs/build/nest/facets/term-stats.html index 0f803ce9b1a..0d0325539a7 100644 --- a/new_docs/build/nest/facets/term-stats.html +++ b/new_docs/build/nest/facets/term-stats.html @@ -1,10 +1,10 @@ Nest - Connecting

NEST

Documentation

Term Stats Facet

-

The terms_stats facet combines both the terms and statistical allowing to compute stats computed on a field, per term value driven by another field. For example:

+

The terms_stats facet combines both the terms and statistical allowing you to obtain stats computed on a field, per term value driven by another field. For example:

this.ConnectedClient.Search<ElasticSearchProject>(s=>s
     .From(0)
     .Size(10)
     .MatchAll()
     .FacetTerm(t => t.OnField(f => f.Country).Size(20))
 );
-

See original docs for more information

+

See original docs for more information.

\ No newline at end of file diff --git a/new_docs/build/nest/facets/terms.html b/new_docs/build/nest/facets/terms.html index 821142c2731..b0eb1bf9637 100644 --- a/new_docs/build/nest/facets/terms.html +++ b/new_docs/build/nest/facets/terms.html @@ -1,10 +1,10 @@ Nest - Connecting

NEST

Documentation

Terms Facet

-

Allow to specify field facets that return the N most frequent terms. For example:

+

Allows you to specify field facets that return the N most frequent terms. For example:

this.ConnectedClient.Search<ElasticSearchProject>(s=>s
     .From(0)
     .Size(10)
     .MatchAll()
     .FacetTerm(t => t.OnField(f => f.Country).Size(20))
 );
-

See original docs for more information

+

See original docs for more information.

\ No newline at end of file diff --git a/new_docs/build/nest/handling-responses.html b/new_docs/build/nest/handling-responses.html index 61461b75c0e..ab3e8deee1e 100644 --- a/new_docs/build/nest/handling-responses.html +++ b/new_docs/build/nest/handling-responses.html @@ -6,8 +6,8 @@ IElasticsearchResponse ConnectionStatus { get; } ElasticInferrer Infer { get; } } -

IsValid will return whether a response is valid or not. A response is usually only valid when a HTTP return result in the 200 range was returned. Some calls allow for 404 to be a valid response too however.

+

IsValid will return whether a response is valid or not. A response is usually only valid when an HTTP return result in the 200 range was returned. Some calls allow for 404 to be a valid response too however.

If a response returns 200 in Elasticsearch sometimes it will contain more information on the validity of the call inside its response. It's highly recommended to read the documentation for a call and check for these properties on the responses as well.

-

ConnectionStatus is the response as it was returned by Elasticsearch.net it's section on +

ConnectionStatus is the response as it was returned by Elasticsearch.net. It's section on handling responses applies here as well.

\ No newline at end of file diff --git a/new_docs/build/nest/index-type-inference.html b/new_docs/build/nest/index-type-inference.html index 88206aafa8d..125c6ad08f5 100644 --- a/new_docs/build/nest/index-type-inference.html +++ b/new_docs/build/nest/index-type-inference.html @@ -15,7 +15,7 @@ }; var index = client.Index(person);

This will index the object to /my-default-index/person/1.

-

NEST is smart enough to infer the index and typename for the Person CLR type. It was also able to get the id of 1 by convention of looking for Id property on the specified object. Where it will look for the Id can be specified using the ElasticType attribute.

+

NEST is smart enough to infer the index and typename for the Person CLR type. It was also able to get the id of 1 by the convention of looking for Id property on the specified object. Where it will look for the Id can be specified using the ElasticType attribute.

As noted in the quick start you can always pass explicit values for infered ones.

var index = client.Index(person, i=>i
     .Index("another-index")
@@ -27,7 +27,7 @@
 

This will index the document using /another-index/another-type/1-should-not-be-the-id?refresh=true&&ttl=1m as the url.

There are a couple of places within NEST where inference comes in to play

Index name inference

-

Whenever an explicit index name is not provided nest will look to see if the type has it's own default index name on the connection settings.

+

Whenever an explicit index name is not provided NEST will look to see if the type has it's own default index name on the connection settings.

 settings.MapDefaultTypeIndices(d=>d
     .Add(typeof(MyType), "my-type-index")
  );
@@ -40,7 +40,7 @@ 

Index name inference

client.Search<Person>()

MyType defaults to my-type-index because it is explicitly configured but Person will default to the global fallback my-default-index.

Type name inference

-

Whenever nest needs a type name but is not given one explicitly it will use the given CLR type to infer it's elasticsearch type name.

+

Whenever NEST needs a type name but is not given one explicitly it will use the given CLR type to infer it's Elasticsearch type name.

settings.MapDefaultTypeNames(d=>d
     .Add(typeof(MyType), "MY_TYPO")
 );
@@ -50,26 +50,26 @@ 

Type name inference

// searches in /inferred-index/person/_search client.Search<Person>(); -

Another way of setting an explicit infer value for a type is through setting an attribute

+

Another way of setting an explicit inferred value for a type is through setting an attribute

[ElasticType(Name="automobile")]
 public class Car {} 
-

As you can also see in the search example is that NEST by default lowercases typenames that due not have a configured infer value.

+

As you can also see in the search example, NEST by default lowercases typenames that do not have a configured inferred value.

settings.SetDefaultTypeNameInferrer(t=>t.Name.ToUpperInvariant());
-

now all type names that have not been explictly specified or have not been explicitly configured will be uppercased.

-

Prior to NEST 1.0 typenames were by default lowercases AND pluralized, if you want this behaviour back call

+

Now all type names that have not been explictly specified or have not been explicitly configured will be uppercased.

+

Prior to NEST 1.0 typenames were by default lowercased AND pluralized, if you want this behaviour back use

settings.PluralizeTypeNames();
 

Property name inference

-

In many places NEST allows you to pass property names and json paths as C# expressions i.e

+

In many places NEST allows you to pass property names and JSON paths as C# expressions i.e

.Query(q=>q.Term(p=>p.Followers.First().FirstName, "martijn"))
-

Or while indexing property names need to be translated to json.

+

Or while indexing property names need to be translated to JSON.

NEST by default will camelCase properties. So followers.firstName in the previous example.

This can be configured by setting

settings.SetDefaultPropertyNameInferrer(p=>p);
 

This will leave property names untouched.

Properties marked with [ElasticAttibute(Name="")] or [JsonProperty(Name="")] will pass the configured name verbatim.

Id inference

-

Whenever an object is passed that needs to specify an id (i.e index, bulk operations) the object is inspected to see if it has an Id property and if so it's value will be used.

-

This inspection happens once per type and the resulting function that given an object of type T returns its id is cached per T throughout the applications lifetime.

+

Whenever an object is passed that needs to specify an id (i.e index, bulk operations) the object is inspected to see if it has an Id property and if so, that value will be used.

+

This inspection happens once per type. The result of the function call that returns the id for an object of type T is cached; therfore, it is only called once per object of type T throughout the applications lifetime.

An example of this is at the top of this documentation where the Index() call could figure out the object's id was 1.

You can control which propery holds the Id:

[ElasticType(IdProperty="CrazyGuid")]
diff --git a/new_docs/build/nest/indices/analyze.html b/new_docs/build/nest/indices/analyze.html
index 5bf5a1ae269..68a6b4f522b 100644
--- a/new_docs/build/nest/indices/analyze.html
+++ b/new_docs/build/nest/indices/analyze.html
@@ -1,5 +1,5 @@
 Nest - Connecting

NEST

Documentation

Analyze

-

Performs the analysis process on a text and return the tokens breakdown of the text.

+

Performs the analysis process on the specified text and returns the token breakdown for the text.

Analyze using default index's default analyzer

var text = "this is a string with some spaces and stuff";
 var r = this.ConnectedClient.Analyze(text);
diff --git a/new_docs/build/nest/indices/create-indices.html b/new_docs/build/nest/indices/create-indices.html
index a63a19ba8c1..a068d9b976a 100644
--- a/new_docs/build/nest/indices/create-indices.html
+++ b/new_docs/build/nest/indices/create-indices.html
@@ -1,7 +1,7 @@
 Nest - Connecting

NEST

Documentation

Create index

-

The create index API allows to instantiate an index. ElasticSearch provides support for multiple indices, including executing operations across several indices. Each index created can have specific settings associated with it.

+

The create index API allows to instantiate an index. Elasticsearch provides support for multiple indices, including executing operations across several indices. Each index created can have specific settings associated with it.

Note

-

When adding settings strip the index. prefix when passing settings found for example here:http://www.elasticsearch.org/guide/reference/index-modules/

+

When adding settings strip the index. prefix. This applies to settings found in the Index Module documentation.

Simple example

var client = this.ConnectedClient;
 var settings = new IndexSettings();
diff --git a/new_docs/build/nest/indices/delete-indices.html b/new_docs/build/nest/indices/delete-indices.html
index 00dfce539f7..5d52f123fbf 100644
--- a/new_docs/build/nest/indices/delete-indices.html
+++ b/new_docs/build/nest/indices/delete-indices.html
@@ -1,5 +1,5 @@
 Nest - Connecting

NEST

Documentation

Delete Index

-

The delete index API allows to delete an existing index.

+

The delete index API allows you to delete an existing index.

The delete index API can also be applied to more than one index, or on _all indices (be careful!). All indices will also be deleted when no specific index is provided. In order to disable allowing to delete all indices, set action.disable_delete_all_indices setting in the config to true.

Examples

Using the default index

diff --git a/new_docs/build/nest/indices/delete-mapping.html b/new_docs/build/nest/indices/delete-mapping.html index 4e2eb80981a..2133daab7bb 100644 --- a/new_docs/build/nest/indices/delete-mapping.html +++ b/new_docs/build/nest/indices/delete-mapping.html @@ -1,6 +1,6 @@ Nest - Connecting

NEST

Documentation

Delete Mapping

-

Allow to delete a mapping (type) along with its data. The REST endpoint is /{index}/{type} with DELETE method.

-

Note, most times, it make more sense to reindex the data into a fresh index compared to delete large chunks of it.

+

Allows you to delete a mapping (type) along with its data. The REST endpoint is /{index}/{type} with DELETE method.

+

Note: Most times, it make more sense to reindex the data into a fresh index as compared to deleting large chunks of it.

Examples

Using the default index and the inferred type name

this.ConnectedClient.DeleteMapping<ElasticSearchProject>()
diff --git a/new_docs/build/nest/indices/get-mapping.html b/new_docs/build/nest/indices/get-mapping.html
index 0a014b37bec..4a36868da33 100644
--- a/new_docs/build/nest/indices/get-mapping.html
+++ b/new_docs/build/nest/indices/get-mapping.html
@@ -1,4 +1,4 @@
 Nest - Connecting

NEST

Documentation

Get mapping

-

The get mapping API allows to retrieve mapping definition of index or index/type.

+

The get mapping API allows you to retrieve mapping definitions of the index or a specific index/type.

var mapping = this.ConnectedClient.GetMapping<ElasticSearchProject>();
 
\ No newline at end of file diff --git a/new_docs/build/nest/indices/open-close.html b/new_docs/build/nest/indices/open-close.html index 7d29b781ed7..7cad7bcbd14 100644 --- a/new_docs/build/nest/indices/open-close.html +++ b/new_docs/build/nest/indices/open-close.html @@ -1,5 +1,5 @@ Nest - Connecting

NEST

Documentation

Open/Close Index

-

The open and close index APIs allow to close an index, and later on opening it. A closed index has almost no overhead on the cluster (except for maintaining its metadata), and is blocked for read/write operations. A closed index can be opened which will then go through the normal recovery process.

+

The open and close index APIs allow you to close an index, and later on open it. A closed index has almost no overhead on the cluster (except for maintaining its metadata), and is blocked for read/write operations. A closed index can be opened which will then go through the normal recovery process.

Open and close and index by name

var r = this.ConnectedClient.CloseIndex(Test.Default.DefaultIndex);
 r = this.ConnectedClient.OpenIndex(Test.Default.DefaultIndex);
diff --git a/new_docs/build/nest/indices/optimize.html b/new_docs/build/nest/indices/optimize.html
index 154c1dab34b..b93b5522c0c 100644
--- a/new_docs/build/nest/indices/optimize.html
+++ b/new_docs/build/nest/indices/optimize.html
@@ -1,5 +1,5 @@
 Nest - Connecting

NEST

Documentation

Optimize

-

The optimize API allows to optimize one or more indices through an API. The optimize process basically optimizes the index for faster search operations (and relates to the number of segments a lucene index within each shard). The optimize operation allows to optimize the number of segments to optimize to.

+

The optimize API allows you to optimize one or more indices through an API. The optimize process basically optimizes the index for faster search operations (and relates to the number of segments a Lucene index maintains within each shard). The optimize operation allows you to specify the maximum number of segments to use during the optimization.

Optimize all

var r = this.ConnectedClient.Optimize();
 

Optimize several indices with parameters

diff --git a/new_docs/build/nest/indices/put-mapping.html b/new_docs/build/nest/indices/put-mapping.html index 07c7680b70c..26f4231664b 100644 --- a/new_docs/build/nest/indices/put-mapping.html +++ b/new_docs/build/nest/indices/put-mapping.html @@ -1,7 +1,7 @@ Nest - Connecting

NEST

Documentation

Put Mapping

The put mapping API allows to register specific mapping definition for a specific type.

Attribute based mapping

-

You can decorate your classes with ElasticProperty and ElasticType attributes to describe how they should be mapped in ES.

+

You can decorate your classes with ElasticProperty and ElasticType attributes to describe how they should be mapped in Elasticsearch.

[ElasticType(
     Name = "elasticsearchprojects2",
     DateDetection = true,
diff --git a/new_docs/build/nest/indices/update-settings.html b/new_docs/build/nest/indices/update-settings.html
index 01d0b4f04d4..6a9f099c313 100644
--- a/new_docs/build/nest/indices/update-settings.html
+++ b/new_docs/build/nest/indices/update-settings.html
@@ -1,6 +1,6 @@
 Nest - Connecting

NEST

Documentation

Update Settings

This call allows you to update the index settings. -NEST whitelists which settings can be updated based on the allowed values mentioned here in the elasticsearch documentation this allows you to reuse an IndexSettings object.

+NEST whitelists which settings can be updated based on the allowed values mentioned here in the Elasticsearch documentation this allows you to reuse an IndexSettings object.

Example

this example first creates an index and then uses the same IndexSettings to update the index.

var index = Guid.NewGuid().ToString();
diff --git a/new_docs/build/nest/query/flt-field.html b/new_docs/build/nest/query/flt-field.html
index c96db8be603..8e14fa1ab21 100644
--- a/new_docs/build/nest/query/flt-field.html
+++ b/new_docs/build/nest/query/flt-field.html
@@ -1,3 +1,3 @@
 Nest - Fuzzy Like This Field Query
\ No newline at end of file
diff --git a/new_docs/build/nest/query/mlt-field.html b/new_docs/build/nest/query/mlt-field.html
index 1140a5c0514..04334b358d4 100644
--- a/new_docs/build/nest/query/mlt-field.html
+++ b/new_docs/build/nest/query/mlt-field.html
@@ -1,3 +1,3 @@
 Nest - More Like This Field Query
\ No newline at end of file
diff --git a/new_docs/build/nest/quick-start.html b/new_docs/build/nest/quick-start.html
index a8b72bba7f1..d721bfcdd3f 100644
--- a/new_docs/build/nest/quick-start.html
+++ b/new_docs/build/nest/quick-start.html
@@ -1,5 +1,5 @@
 Nest - Quick Start

NEST

Documentation

Quick Start

-

NEST is a high level elasticsearch client that still maps very close to the original elasticsearch API. +

NEST is a high level elasticsearch client that still maps very closely to the original elasticsearch API. Requests and Responses have been mapped to CLR objects and NEST also comes with a powerful strongly typed query dsl.

Installing

From the package manager console inside visual studio

@@ -26,9 +26,9 @@

Connecting

defaultIndex: "my-application" ); var client = new ElasticClient(settings); -

Here we create new connection to our node and specify a default index to use when we don't explictly specify one. +

Here we create new a connection to our node and specify a default index to use when we don't explictly specify one. This can greatly reduce the places a magic string or constant has to be used.

-

NOTE: specifying defaultIndex is optional but NEST might throw later on if no index is specified. In fact a simple new ElasticClient() is sufficient to chat with +

NOTE: specifying defaultIndex is optional but NEST might throw an exception later on if no index is specified. In fact a simple new ElasticClient() is sufficient to chat with http://localhost:9200 but explicitly specifying connection settings is recommended.

node here is a Uri but can also be an IConnectionPool see the Elasticsearch.net section on connecting

@@ -40,7 +40,7 @@

Indexing

public string Firstname { get; set; } public string Lastname { get; set; } } -

That we would like to index in elasticsearch indexing is now as simple as calling.

+

That we would like to index in elasticsearch. Indexing is now as simple as calling.

var person = new Person
 {
     Id = "1",
@@ -48,7 +48,7 @@ 

Indexing

Lastname = "Laarman" }; var index = client.Index(person); -

This will index the object to /my-application/person/1. NEST is smart enough to infer the index and typename for the Person CLR type. It was also able to get the id of 1 by convention of looking for Id property on the specified object. Where it will look for the Id can be specified using the ElasticType attribute.

+

This will index the object to /my-application/person/1. NEST is smart enough to infer the index and typename for the Person CLR type. It was also able to get the id of 1 through convention, by looking for an Id property on the specified object. Which property it will use for the Id can also be specified using the ElasticType attribute.

The default index and type names are configurable per type see the nest section on connecting

Image you want to override all the defaults for this one call, you should be able to do this with NEST and yes you can. NEST inferring is very powerful but if you want to pass explicit values you can always do so.

var index = client.Index(person, i=>i
@@ -68,9 +68,9 @@ 

Searching

.Term(p=>p.Firstname, "martijn") ) ); -

searchResults.Documentsnow holds the first 10 people it knows who's first name is Martijn

-

Please see the section on writing queries how NEST helps you write terse elasticsearch queries.

-

Again the same inferring rules apply as this will hit /my-application/person/_search and the same rule that inferring can be overruled also applies.

+

searchResults.Documents now holds the first 10 people it knows who's first name is Martijn

+

Please see the section on writing queries for details on how NEST helps you write terse elasticsearch queries.

+

Again the same inferring rules apply as this will hit /my-application/person/_search and the same rule that inferring can be overridden also applies.

// uses /other-index/other-type/_search
 var searchResults = client.Search<Person>(s=>s
     .Index("other-index")
diff --git a/new_docs/build/nest/search/basics.html b/new_docs/build/nest/search/basics.html
index 702d238f9ed..56ee301bf7a 100644
--- a/new_docs/build/nest/search/basics.html
+++ b/new_docs/build/nest/search/basics.html
@@ -13,12 +13,12 @@
     .AllIndices()
     ...
 )
-

Or if you want to search one index (thats not the default index)

+

Or if you want to search one index (that is not the default index)

client.Search<MyObject>(s=>s.
     .Index("Index_A")
     ...
 )
-

Remember since elasticsearch 19.8 you can also specify wildcards on index names

+

Remember that since Elasticsearch 19.8 you can also specify wildcards on index names

client.Search<MyObject>(s=>s
     .Index("Index_*")
     ...
@@ -34,7 +34,7 @@
 

This will search on /yourdefaultindex/products,categories,manufacturers/_search and setup a default ConcreteTypeSelector that understands what type each returned document is.

Using

.ConcreteTypeSelector(Func<dynamic, Hit<dynamic>, Type>)
-

you can manually specify the type of each hit based on some json value (on dynamic) or on the hit metadata.

+

you can manually specify the type of each hit based on some JSON value (on dynamic) or on the hit metadata.

Routing

You can specify the routing for the search request using

.Routing("routevalue")
diff --git a/new_docs/build/nest/search/fields.html b/new_docs/build/nest/search/fields.html
index d89c93066c8..c3351cc4177 100644
--- a/new_docs/build/nest/search/fields.html
+++ b/new_docs/build/nest/search/fields.html
@@ -3,5 +3,5 @@
 

Using

.Fields(p=>p.Id, p=>p.Name, p=>p.Followers.First().Name, ...)
 

You can limit the returned fields for each hit.

-

An overload taking plain strings also exists

+

An overload taking plain strings also exists.

\ No newline at end of file diff --git a/new_docs/build/nest/search/named-filters.html b/new_docs/build/nest/search/named-filters.html index c92693f2ec3..fe58ce803fe 100644 --- a/new_docs/build/nest/search/named-filters.html +++ b/new_docs/build/nest/search/named-filters.html @@ -2,6 +2,6 @@

Each filter allows you specify a name i.e

.Filter(f=>f.Name("myfilter").Term(...))
 

This will allow you to see on each with which filter applied to it.

-

Right now I'm waiting on this active elasticsearch issue to complete mapping this functionality

+

Right now I'm waiting on this active Elasticsearch issue to complete mapping this functionality

https://github.com/elasticsearch/elasticsearch/issues/3097

\ No newline at end of file diff --git a/new_docs/build/nest/search/scroll.html b/new_docs/build/nest/search/scroll.html index c4818145e24..d94ab33cffa 100644 --- a/new_docs/build/nest/search/scroll.html +++ b/new_docs/build/nest/search/scroll.html @@ -1,5 +1,5 @@ Nest - Connecting

NEST

Documentation

Scroll

-

The scroll api allows you to efficiently page through a large dataset as it keeps the query alive in the cluster.

+

The scroll API allows you to efficiently page through a large dataset as it keeps the query alive in the cluster.

var scanResults = this._client.Search<ElasticSearchProject>(s => s
     .From(0)
     .Size(1)
diff --git a/new_docs/build/nest/search/sort.html b/new_docs/build/nest/search/sort.html
index 6b2dec6cc57..9b54cd1928a 100644
--- a/new_docs/build/nest/search/sort.html
+++ b/new_docs/build/nest/search/sort.html
@@ -1,5 +1,5 @@
 Nest - Connecting

NEST

Documentation

Sort

-

Apply a sort over the search results, do note that sorting and boosting are mutually exclusive.

+

Apply a sort over the search results. Please note that sorting and boosting are mutually exclusive.

.SortAscending(p=> p.Name.Suffix("sort"))
 

or

.SortDescending("name.sort")
diff --git a/new_docs/build/nest/writing-queries.html b/new_docs/build/nest/writing-queries.html
index c1da724a08f..eb5c790b035 100644
--- a/new_docs/build/nest/writing-queries.html
+++ b/new_docs/build/nest/writing-queries.html
@@ -1,27 +1,27 @@
 Nest - Connecting

NEST

Documentation

Writing Queries

-

One of the most important things to grasp using Nest is how to write queries. Nest offers you several possibilities. By the way all examples on this page assume being wrapped in

+

One of the most important things to grasp when using Nest is how to write queries. Nest offers you several possibilities. By the way all examples on this page assume being wrapped in

var result = client.Search<ElasticSearchProject>(s=>s
     .From(0)
     .Size(10)
     ///EXAMPLE HERE
 );
 

Raw strings

-

Although not preffered by me personally many folks like to build their own json strings and just pass that along.

+

Although not preferred by me personally, many folks like to build their own JSON strings and just pass that along.

.QueryRaw("\"match_all\" : { }")
 .FilterRaw("\"match_all\" : { }")
-

Nest does not modify this in anyway and just writes this straight into the json output.

+

Nest does not modify this in anyway and just writes this straight into the JSON output.

Query DSL

-

The preffered way to write queries since it gives you alot of cool feautures.

+

The preferred way to write queries, since it gives you alot of cool features.

Lambda expressions

.Query(q=>q
     .Term(p=>p.Name, "NEST")
 )
-

Here you'll see we can use expressions to adres properties in a type safe matter. This also works for IEnumerable types i.e

+

Here you'll see we can use expressions to address properties in a type safe matter. This also works for IEnumerable types e.g.

.Query(q=>q
     .Term(p=>p.Followers.First().FirstName, "NEST")
 )
-

Because these property lookups are expressions you dont have to do any null checks. The previous would expand to the followers.firstName property name.

-

Of course if you need to pass the property name as string Nest will allow you to do so.

+

Because these property lookups are expressions you don't have to do any null checks. The previous would expand to the followers.firstName property name.

+

Of course if you need to pass the property name as string NEST will allow you to do so.

.Query(q=>q
     .Term("followers.firstName", "martijn")
 )
@@ -38,11 +38,11 @@ 

Lambda expressions

) ) ) -

similarly Filter<T>.[Filter]() methods exist for filters.

+

Similarly Filter<T>.[Filter]() methods exist for filters.

Boolean queries

-

As can be seen in the previous example writing out boolean queries can turn into a really tedious and verbose effort. Luckily Nest supports bitwise operators and so we can rewrite the previous as such:

+

As can be seen in the previous example writing out boolean queries can turn into a really tedious and verbose effort. Luckily NEST supports bitwise operators and so we can rewrite the previous as such:

.Query(q=>q.MatchAll() && termQuery)
-

Note how we are mixing and matching the lambda and static queries here

+

Note how we are mixing and matching the lambda and static queries here.

Similary an OR looks like this

.Query(q=>q
     q.Term("name", "Nest")
@@ -53,31 +53,31 @@ 

Boolean queries

q.Term("language", "php") && !q.Term("name", "Elastica") ) -

This will query for all the php clients except Elastica

-

You can mix and match this to any complexity until it satisfies your query requirements.

+

This will query for all the php clients except Elastica.

+

You can mix and match this to any level of complexity until it satisfies your query requirements.

.Query(q=>q
     (q.Term("language", "php")
         && !q.Term("name", "Elastica")
     )
     ||
-    q.Term("name", "Nest")
+    q.Term("name", "NEST")
 )
-

will query all php clients except elastica or where the name equals Nest.

+

Will query all php clients except 'Elasticaor where the name equalsNEST`.

Clean output support

Normally writing three boolean must clauses looks like this (psuedo code)

must
     clause1
     clause2
     clause3
-

A naive implemenation of the bitwise operators would make all the queries sent to elasticsearch look like

+

A naive implemenation of the bitwise operators would make all the queries sent to Elasticsearch look like

must
     must
         clause1
         clause2
     clause3
-

This degrades rather rapidly so and makes inspecting generated queries quite a chore. Nest does it's best to detect these cases and always write them in the first clean form.

+

This degrades rather rapidly and makes inspecting generated queries quite a chore. NEST does it's best to detect these cases and will always write them in the first, cleaner form.

Conditionless queries

-

Writing complex boolean queries is one thing but more often then not you'll want to make decisions on how to query based on user input.

+

Writing complex boolean queries is one thing, but more often then not you'll want to make decisions on how to query based on user input.

public class UserInput
 {
     public string Name { get; set; }
@@ -96,15 +96,15 @@ 

Conditionless queries

query &= q.Range(r=>r.OnField(p=>p.Loc).From(userInput.Loc.Value)) return query; }) -

This again turns tedious and verbose rather quickly too. Therefor nest allows you to write the previous query as:

+

This again becomes tedious and verbose rather quickly as well. Therefore, NEST allows you to write the previous query as:

.Query(q=>
     q.Term(p=>p.Name, userInput.Name);
     && q.Term("followers.firstName", userInput.FirstName)
     && q.Range(r=>r.OnField(p=>p.Loc).From(userInput.Loc))
 )
-

If any of the queries would result in an empty query they won't be sent to elasticsearch.

+

If any of the queries would result in an empty query they won't be sent to Elasticsearch.

So if all the terms are null (or empty string) on userInput except userInput.Loc it wouldn't even wrap the range query in a boolean query but just issue a plain range query.

-

If all of them empty it will result in a match_all query.

+

If all of them are empty it will result in a match_all query.

This conditionless behavior is turned on by default but can be turned of like so:

 var result = client.Search<ElasticSearchProject>(s=>s
     .From(0)
@@ -119,7 +119,7 @@ 

Conditionless queries

&& q.Strict(false).Range(r=>r.OnField(p=>p.Loc).From(userInput.Loc)) )

In this example if userInput.Name is null or empty it will result in a DslException. The range query will use conditionless logic no matter if the SearchDescriptor uses .Strict() or not.

-

Also good to note is that conditionless query logic propagates:

+

Please note that conditionless query logic propagates:

q.Strict().Term(p=>p.Name, userInput.Name);
 && q.Term("followers.firstName", userInput.FirstName)
 && q.Filtered(fq => fq
@@ -128,5 +128,5 @@ 

Conditionless queries

&& qff.Terms(p => p.Loc, userInput.Loc) ) ) -

If both userInput.Countries and userInput.Loc are null or empty the entire filtered query will be not be issued.

+

If both userInput.Countries and userInput.Loc are null or empty the entire filtered query will not be issued.

\ No newline at end of file diff --git a/new_docs/build/scripts/html5shiv.js b/new_docs/build/scripts/html5shiv.js new file mode 100644 index 00000000000..205bdfe47c5 --- /dev/null +++ b/new_docs/build/scripts/html5shiv.js @@ -0,0 +1,301 @@ +/** +* @preserve HTML5 Shiv prev3.7.1 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed +*/ +;(function(window, document) { +/*jshint evil:true */ + /** version */ + var version = '3.7.0'; + + /** Preset options */ + var options = window.html5 || {}; + + /** Used to skip problem elements */ + var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i; + + /** Not all elements can be cloned in IE **/ + var saveClones = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i; + + /** Detect whether the browser supports default html5 styles */ + var supportsHtml5Styles; + + /** Name of the expando, to work with multiple documents or to re-shiv one document */ + var expando = '_html5shiv'; + + /** The id for the the documents expando */ + var expanID = 0; + + /** Cached data for each document */ + var expandoData = {}; + + /** Detect whether the browser supports unknown elements */ + var supportsUnknownElements; + + (function() { + try { + var a = document.createElement('a'); + a.innerHTML = ''; + //if the hidden property is implemented we can assume, that the browser supports basic HTML5 Styles + supportsHtml5Styles = ('hidden' in a); + + supportsUnknownElements = a.childNodes.length == 1 || (function() { + // assign a false positive if unable to shiv + (document.createElement)('a'); + var frag = document.createDocumentFragment(); + return ( + typeof frag.cloneNode == 'undefined' || + typeof frag.createDocumentFragment == 'undefined' || + typeof frag.createElement == 'undefined' + ); + }()); + } catch(e) { + // assign a false positive if detection fails => unable to shiv + supportsHtml5Styles = true; + supportsUnknownElements = true; + } + + }()); + + /*--------------------------------------------------------------------------*/ + + /** + * Creates a style sheet with the given CSS text and adds it to the document. + * @private + * @param {Document} ownerDocument The document. + * @param {String} cssText The CSS text. + * @returns {StyleSheet} The style element. + */ + function addStyleSheet(ownerDocument, cssText) { + var p = ownerDocument.createElement('p'), + parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement; + + p.innerHTML = 'x'; + return parent.insertBefore(p.lastChild, parent.firstChild); + } + + /** + * Returns the value of `html5.elements` as an array. + * @private + * @returns {Array} An array of shived element node names. + */ + function getElements() { + var elements = html5.elements; + return typeof elements == 'string' ? elements.split(' ') : elements; + } + + /** + * Returns the data associated to the given document + * @private + * @param {Document} ownerDocument The document. + * @returns {Object} An object of data. + */ + function getExpandoData(ownerDocument) { + var data = expandoData[ownerDocument[expando]]; + if (!data) { + data = {}; + expanID++; + ownerDocument[expando] = expanID; + expandoData[expanID] = data; + } + return data; + } + + /** + * returns a shived element for the given nodeName and document + * @memberOf html5 + * @param {String} nodeName name of the element + * @param {Document} ownerDocument The context document. + * @returns {Object} The shived element. + */ + function createElement(nodeName, ownerDocument, data){ + if (!ownerDocument) { + ownerDocument = document; + } + if(supportsUnknownElements){ + return ownerDocument.createElement(nodeName); + } + if (!data) { + data = getExpandoData(ownerDocument); + } + var node; + + if (data.cache[nodeName]) { + node = data.cache[nodeName].cloneNode(); + } else if (saveClones.test(nodeName)) { + node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode(); + } else { + node = data.createElem(nodeName); + } + + // Avoid adding some elements to fragments in IE < 9 because + // * Attributes like `name` or `type` cannot be set/changed once an element + // is inserted into a document/fragment + // * Link elements with `src` attributes that are inaccessible, as with + // a 403 response, will cause the tab/window to crash + // * Script elements appended to fragments will execute when their `src` + // or `text` property is set + return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node; + } + + /** + * returns a shived DocumentFragment for the given document + * @memberOf html5 + * @param {Document} ownerDocument The context document. + * @returns {Object} The shived DocumentFragment. + */ + function createDocumentFragment(ownerDocument, data){ + if (!ownerDocument) { + ownerDocument = document; + } + if(supportsUnknownElements){ + return ownerDocument.createDocumentFragment(); + } + data = data || getExpandoData(ownerDocument); + var clone = data.frag.cloneNode(), + i = 0, + elems = getElements(), + l = elems.length; + for(;i