Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/build/nest/core/multi-search.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
<p>The multi search API allows to execute several search requests within the same API.</p>
<h3 id="fluent-syntax">Fluent Syntax</h3>
<pre><code>var result = client.MultiSearch(ms =&gt; ms
.Search&lt;ElasticsearchProject&gt;(&quot;esproj&quot;, s =&gt; s.MatchAll())
.Search&lt;ElasticsearchProject&gt;(&quot;projects&quot;, s =&gt; s.MatchAll())
.Search&lt;Person&gt;(&quot;people&quot;, s =&gt; s.MatchAll())
);
</code></pre><h3 id="object-initializer-syntax">Object Initializer Syntax</h3>
<pre><code>var request = new MultiSearchRequest
{
Operations = new Dictionary&lt;string, ISearchRequest&gt;
{
{ &quot;esproj&quot;, new SearchRequest
{ &quot;projects&quot;, new SearchRequest&lt;ElasticsearchProject&gt;
{
Query = new QueryContainer(new MatchAllQuery())
}
},
{ &quot;people&quot;, new SearchRequest
{ &quot;people&quot;, new SearchRequest&lt;Person&gt;
{
Query = new QueryContainer(new MatchAllQuery())
}
Expand All @@ -28,7 +28,7 @@ <h3 id="fluent-syntax">Fluent Syntax</h3>
</code></pre><h2 id="handling-the-multi-search-response">Handling the Multi Search Response</h2>
<p><code>MultiSearch</code> returns an <code>IMultiSearchResponse</code> object. Each <code>SearchResponse&lt;T&gt;</code> can be retrieved using the corresponding name that was specified in the request.</p>
<pre><code>// returns a SearchResponse&lt;ElasticsearchProject&gt;&gt;
var projects = result.GetResponse&lt;ElasticsearchProject&gt;(&quot;esproj&quot;);
var projects = result.GetResponse&lt;ElasticsearchProject&gt;(&quot;projects&quot;);

// returns a SearchResponse&lt;Person&gt;&gt;
var people = result.GetResponse&lt;Person&gt;(&quot;people&quot;);
Expand Down
8 changes: 4 additions & 4 deletions docs/contents/nest/core/multi-search.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The multi search API allows to execute several search requests within the same A
### Fluent Syntax

var result = client.MultiSearch(ms => ms
.Search<ElasticsearchProject>("esproj", s => s.MatchAll())
.Search<ElasticsearchProject>("projects", s => s.MatchAll())
.Search<Person>("people", s => s.MatchAll())
);

Expand All @@ -24,12 +24,12 @@ The multi search API allows to execute several search requests within the same A
{
Operations = new Dictionary<string, ISearchRequest>
{
{ "esproj", new SearchRequest
{ "projects", new SearchRequest<ElasticsearchProject>
{
Query = new QueryContainer(new MatchAllQuery())
}
},
{ "people", new SearchRequest
{ "people", new SearchRequest<Person>
{
Query = new QueryContainer(new MatchAllQuery())
}
Expand All @@ -44,7 +44,7 @@ The multi search API allows to execute several search requests within the same A
`MultiSearch` returns an `IMultiSearchResponse` object. Each `SearchResponse<T>` can be retrieved using the corresponding name that was specified in the request.

// returns a SearchResponse<ElasticsearchProject>>
var projects = result.GetResponse<ElasticsearchProject>("esproj");
var projects = result.GetResponse<ElasticsearchProject>("projects");

// returns a SearchResponse<Person>>
var people = result.GetResponse<Person>("people");
2 changes: 1 addition & 1 deletion src/Nest/Resolvers/Converters/MultiSearchConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
{
var descriptor = m.Descriptor.Value;
var concreteTypeSelector = descriptor.TypeSelector;
var baseType = m.Descriptor.Value.ClrType;
var baseType = m.Descriptor.Value.ClrType ?? typeof(object);

var generic = MakeDelegateMethodInfo.MakeGenericMethod(baseType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
<Compile Include="Reproduce\Reproduce994Tests.cs" />
<Compile Include="Reproduce\Reproduce986Tests.cs" />
<Compile Include="Reproduce\Reproduce960Tests.cs" />
<Compile Include="Reproduce\Reproduce1279Tests.cs" />
<Compile Include="Search\Filter\AndOrNotFilterTests.cs" />
<Compile Include="Search\Filter\ScriptFilterTests.cs" />
<Compile Include="Search\Filter\MissingExistsFilterTests.cs" />
Expand Down
40 changes: 40 additions & 0 deletions src/Tests/Nest.Tests.Integration/Reproduce/Reproduce1279Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FluentAssertions;
using Nest.Tests.MockData.Domain;
using Newtonsoft.Json.Linq;

namespace Nest.Tests.Integration.Reproduce
{
[TestFixture]
public class Reproduce1279Tests : IntegrationTests
{
[Test]
public void MultiSearchNullArgumentException()
{
var request = new MultiSearchRequest
{
Operations = new Dictionary<string, ISearchRequest>
{
{ "test", new SearchRequest
{
Query = new QueryContainer(new MatchAllQuery()),
Types = new TypeNameMarker[] { typeof(Product), typeof(ElasticsearchProject) },
TypeSelector = (o, h) => typeof(ElasticsearchProject)
}
}
}
};

var result = Client.MultiSearch(request);
result.IsValid.Should().BeTrue();
var response = result.GetResponse<object>("test");
var projects = response.Documents.OfType<ElasticsearchProject>().ToList();
projects.Count.Should().BeGreaterThan(0);
}
}
}