Skip to content

Commit c45bfa1

Browse files
committed
Support for multi termvectors
1 parent 0ec0cd8 commit c45bfa1

File tree

6 files changed

+108
-12
lines changed

6 files changed

+108
-12
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using Elasticsearch.Net;
6+
7+
namespace Nest
8+
{
9+
public partial class MtermvectorsDescriptor<T> : DocumentPathDescriptorBase<MtermvectorsDescriptor<T>, T, MtermvectorsRequestParameters>
10+
, IPathInfo<MtermvectorsRequestParameters> where T : class
11+
{
12+
ElasticsearchPathInfo<MtermvectorsRequestParameters> IPathInfo<MtermvectorsRequestParameters>.ToPathInfo(IConnectionSettingsValues settings)
13+
{
14+
var pathInfo = base.ToPathInfo<MtermvectorsRequestParameters>(settings, this._QueryString);
15+
pathInfo.HttpMethod = PathInfoHttpMethod.POST;
16+
17+
return pathInfo;
18+
}
19+
}
20+
}

src/Nest/DSL/_Descriptors.generated.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4081,45 +4081,45 @@ public MultiSearchDescriptor SearchType(SearchTypeOptions search_type)
40814081
///http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/docs-multi-termvectors.html
40824082
///</pre>
40834083
///</summary>
4084-
public partial class MtermvectorsDescriptor
4084+
public partial class MtermvectorsDescriptor<T>
40854085
{
40864086
internal MtermvectorsRequestParameters _QueryString = new MtermvectorsRequestParameters();
40874087

40884088

40894089
///<summary>A comma-separated list of documents ids. You must define ids as parameter or set &quot;ids&quot; or &quot;docs&quot; in the request body</summary>
4090-
public MtermvectorsDescriptor Ids(params string[] ids)
4090+
public MtermvectorsDescriptor<T> Ids(params string[] ids)
40914091
{
40924092
this._QueryString.Ids(ids);
40934093
return this;
40944094
}
40954095

40964096

40974097
///<summary>Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body &quot;params&quot; or &quot;docs&quot;.</summary>
4098-
public MtermvectorsDescriptor TermStatistics(bool term_statistics = true)
4098+
public MtermvectorsDescriptor<T> TermStatistics(bool term_statistics = true)
40994099
{
41004100
this._QueryString.TermStatistics(term_statistics);
41014101
return this;
41024102
}
41034103

41044104

41054105
///<summary>Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body &quot;params&quot; or &quot;docs&quot;.</summary>
4106-
public MtermvectorsDescriptor FieldStatistics(bool field_statistics = true)
4106+
public MtermvectorsDescriptor<T> FieldStatistics(bool field_statistics = true)
41074107
{
41084108
this._QueryString.FieldStatistics(field_statistics);
41094109
return this;
41104110
}
41114111

41124112

41134113
///<summary>A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body &quot;params&quot; or &quot;docs&quot;.</summary>
4114-
public MtermvectorsDescriptor Fields(params string[] fields)
4114+
public MtermvectorsDescriptor<T> Fields(params string[] fields)
41154115
{
41164116
this._QueryString.Fields(fields);
41174117
return this;
41184118
}
41194119

41204120

41214121
///<summary>A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body &quot;params&quot; or &quot;docs&quot;.</summary>
4122-
public MtermvectorsDescriptor Fields<T>(params Expression<Func<T, object>>[] typedPathLookups) where T : class
4122+
public MtermvectorsDescriptor<T> Fields(params Expression<Func<T, object>>[] typedPathLookups)
41234123
{
41244124
if (!typedPathLookups.HasAny())
41254125
return this;
@@ -4130,47 +4130,47 @@ public MtermvectorsDescriptor Fields<T>(params Expression<Func<T, object>>[] typ
41304130

41314131

41324132
///<summary>Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body &quot;params&quot; or &quot;docs&quot;.</summary>
4133-
public MtermvectorsDescriptor Offsets(bool offsets = true)
4133+
public MtermvectorsDescriptor<T> Offsets(bool offsets = true)
41344134
{
41354135
this._QueryString.Offsets(offsets);
41364136
return this;
41374137
}
41384138

41394139

41404140
///<summary>Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body &quot;params&quot; or &quot;docs&quot;.</summary>
4141-
public MtermvectorsDescriptor Positions(bool positions = true)
4141+
public MtermvectorsDescriptor<T> Positions(bool positions = true)
41424142
{
41434143
this._QueryString.Positions(positions);
41444144
return this;
41454145
}
41464146

41474147

41484148
///<summary>Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body &quot;params&quot; or &quot;docs&quot;.</summary>
4149-
public MtermvectorsDescriptor Payloads(bool payloads = true)
4149+
public MtermvectorsDescriptor<T> Payloads(bool payloads = true)
41504150
{
41514151
this._QueryString.Payloads(payloads);
41524152
return this;
41534153
}
41544154

41554155

41564156
///<summary>Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body &quot;params&quot; or &quot;docs&quot;.</summary>
4157-
public MtermvectorsDescriptor Preference(string preference)
4157+
public MtermvectorsDescriptor<T> Preference(string preference)
41584158
{
41594159
this._QueryString.Preference(preference);
41604160
return this;
41614161
}
41624162

41634163

41644164
///<summary>Specific routing value. Applies to all returned documents unless otherwise specified in body &quot;params&quot; or &quot;docs&quot;.</summary>
4165-
public MtermvectorsDescriptor Routing(string routing)
4165+
public MtermvectorsDescriptor<T> Routing(string routing)
41664166
{
41674167
this._QueryString.Routing(routing);
41684168
return this;
41694169
}
41704170

41714171

41724172
///<summary>Parent id of documents. Applies to all returned documents unless otherwise specified in body &quot;params&quot; or &quot;docs&quot;.</summary>
4173-
public MtermvectorsDescriptor Parent(string parent)
4173+
public MtermvectorsDescriptor<T> Parent(string parent)
41744174
{
41754175
this._QueryString.Parent(parent);
41764176
return this;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using Newtonsoft.Json;
6+
7+
namespace Nest
8+
{
9+
public interface IMultiTermVectorResponse : IResponse
10+
{
11+
IEnumerable<TermVectorResponse> Documents { get; }
12+
}
13+
14+
[JsonObject]
15+
public class MultiTermVectorResponse : BaseResponse, IMultiTermVectorResponse
16+
{
17+
public MultiTermVectorResponse()
18+
{
19+
IsValid = true;
20+
}
21+
22+
[JsonProperty("docs")]
23+
public IEnumerable<TermVectorResponse> Documents { get; internal set; }
24+
}
25+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Elasticsearch.Net;
7+
8+
namespace Nest
9+
{
10+
public partial class ElasticClient
11+
{
12+
public IMultiTermVectorResponse MultiTermVectors<T>(Func<MtermvectorsDescriptor<T>, MtermvectorsDescriptor<T>> multiTermVectorsSelector)
13+
where T : class
14+
{
15+
return this.Dispatch<MtermvectorsDescriptor<T>, MtermvectorsRequestParameters, MultiTermVectorResponse>(
16+
multiTermVectorsSelector,
17+
(p, d) => this.RawDispatch.MtermvectorsDispatch<MultiTermVectorResponse>(p, d)
18+
);
19+
}
20+
21+
public Task<IMultiTermVectorResponse> MultiTermVectorsAsync<T>(Func<MtermvectorsDescriptor<T>, MtermvectorsDescriptor<T>> multiTermVectorsSelector)
22+
where T : class
23+
{
24+
return this.DispatchAsync<MtermvectorsDescriptor<T>, MtermvectorsRequestParameters, MultiTermVectorResponse, IMultiTermVectorResponse>(
25+
multiTermVectorsSelector,
26+
(p, d) => this.RawDispatch.MtermvectorsDispatchAsync<MultiTermVectorResponse>(p, d)
27+
);
28+
}
29+
}
30+
}

src/Nest/IElasticClient.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,24 @@ ITermVectorResponse TermVector<T>(Func<TermvectorDescriptor<T>, TermvectorDescri
10531053
/// <returns></returns>
10541054
Task<ITermVectorResponse> TermVectorAsync<T>(Func<TermvectorDescriptor<T>, TermvectorDescriptor<T>> termVectorSelector)
10551055
where T : class;
1056+
1057+
/// <summary>
1058+
/// Multi termvectors API allows to get multiple termvectors based on an index, type and id.
1059+
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-multi-termvectors.html
1060+
/// </summary>
1061+
/// <typeparam name="T">The type used to infer the default index and typename</typeparam>
1062+
/// <param name="multiTermVectorsSelector">The descriptor describing the multi termvectors operation</param>
1063+
IMultiTermVectorResponse MultiTermVectors<T>(Func<MtermvectorsDescriptor<T>, MtermvectorsDescriptor<T>> multiTermVectorsSelector)
1064+
where T : class;
1065+
1066+
/// <summary>
1067+
/// Multi termvectors API allows to get multiple termvectors based on an index, type and id.
1068+
/// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-multi-termvectors.html
1069+
/// </summary>
1070+
/// <typeparam name="T">The type used to infer the default index and typename</typeparam>
1071+
/// <param name="multiTermVectorsSelector">The descriptor describing the multi termvectors operation</param>
1072+
Task<IMultiTermVectorResponse> MultiTermVectorsAsync<T>(Func<MtermvectorsDescriptor<T>, MtermvectorsDescriptor<T>> multiTermVectorsSelector)
1073+
where T : class;
10561074

10571075
/// <summary>
10581076
/// The suggest feature suggests similar looking terms based on a provided text by using a suggester.

src/Nest/Nest.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,12 @@
134134
<Compile Include="Domain\Repository\Snapshot.cs" />
135135
<Compile Include="Domain\Repository\SnapshotRestore.cs" />
136136
<Compile Include="Domain\Responses\GetSnapshotResponse.cs" />
137+
<Compile Include="Domain\Responses\MultiTermVectorResponse.cs" />
137138
<Compile Include="Domain\Responses\RestoreResponse.cs" />
138139
<Compile Include="Domain\Responses\SnapshotResponse.cs" />
139140
<Compile Include="DSL\DeleteSnapshotDescriptor.cs" />
140141
<Compile Include="DSL\GetSnapshotDescriptor.cs" />
142+
<Compile Include="DSL\MultiTermVectorsDescriptor.cs" />
141143
<Compile Include="DSL\RestoreDescriptor.cs" />
142144
<Compile Include="DSL\SnapshotDescriptor.cs" />
143145
<Compile Include="DSL\DeleteRepositoryDescriptor.cs" />
@@ -253,6 +255,7 @@
253255
<Compile Include="DSL\UpdateSettingsDescriptor.cs" />
254256
<Compile Include="DSL\Paths\IndexOptionalPathDescriptor.cs" />
255257
<Compile Include="ElasticClient-Exists.cs" />
258+
<Compile Include="ElasticClient-MultiTermVectors.cs" />
256259
<Compile Include="ElasticClient-Snapshot.cs" />
257260
<Compile Include="ElasticClient-Restore.cs" />
258261
<Compile Include="ElasticClient-Repository.cs" />

0 commit comments

Comments
 (0)