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
35 changes: 20 additions & 15 deletions src/Nest/Domain/Responses/MultiTermVectorResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,26 @@

namespace Nest
{
public interface IMultiTermVectorResponse : IResponse
{
IEnumerable<TermVectorResponse> Documents { get; }
}
public interface IMultiTermVectorResponse : IResponse
{
[Obsolete("In 1.x this property does not return metadata for the documents, switch to .Docs or upgrade to 2.0 when its release")]
IEnumerable<TermVectorResponse> Documents { get; }
IEnumerable<MultiTermVectorHit> Docs { get; }
}

[JsonObject]
public class MultiTermVectorResponse : BaseResponse, IMultiTermVectorResponse
{
public MultiTermVectorResponse()
{
IsValid = true;
Documents = new List<TermVectorResponse>();
}
[JsonObject]
public class MultiTermVectorResponse : BaseResponse, IMultiTermVectorResponse
{
public MultiTermVectorResponse()
{
IsValid = true;
Docs = new List<MultiTermVectorHit>();
}

[JsonProperty("docs")]
public IEnumerable<TermVectorResponse> Documents { get; internal set; }
}
[Obsolete("In 1.x this property does not return metadata for the documents, switch to .Docs or upgrade to 2.0 when its release")]
public IEnumerable<TermVectorResponse> Documents { get { return this.Docs; } }

[JsonProperty("docs")]
public IEnumerable<MultiTermVectorHit> Docs { get; internal set; }
}
}
71 changes: 50 additions & 21 deletions src/Nest/Domain/Responses/TermVectorResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,54 @@

namespace Nest
{
public interface ITermVectorResponse : IResponse
{
bool Found { get; }
IDictionary<string, TermVector> TermVectors { get; }
}

[JsonObject]
public class TermVectorResponse : BaseResponse, ITermVectorResponse
{
public TermVectorResponse()
{
IsValid = true;
TermVectors = new Dictionary<string, TermVector>();
}

[JsonProperty("found")]
public bool Found { get; internal set; }

[JsonProperty("term_vectors")]
public IDictionary<string, TermVector> TermVectors { get; internal set; }
}
public interface ITermVectorResponse : IResponse
{
bool Found { get; }
IDictionary<string, TermVector> TermVectors { get; }
}

public interface IMultiTermVectorHit : ITermVectorResponse
{
string Index { get; }
string Type { get; }
string Id { get; }
long Version { get; }
long Took { get; }
}

[JsonObject]
public class TermVectorResponse : BaseResponse, ITermVectorResponse
{
public TermVectorResponse()
{
IsValid = true;
TermVectors = new Dictionary<string, TermVector>();
}

[JsonProperty("found")]
public bool Found { get; internal set; }


[JsonProperty("term_vectors")]
public IDictionary<string, TermVector> TermVectors { get; internal set; }
}

public class MultiTermVectorHit : TermVectorResponse, IMultiTermVectorHit
{
[JsonProperty("_index")]
public string Index { get; internal set; }

[JsonProperty("_type")]
public string Type { get; internal set; }

[JsonProperty("_id")]
public string Id { get; internal set; }

[JsonProperty("_version")]
public long Version { get; internal set; }

[JsonProperty("took")]
public long Took { get; internal set; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ public void MultiTermVectorsTest_DocumentsInBody()

result.IsValid.Should().BeTrue();

result.Documents.Should().NotBeNull();
result.Documents.Count().Should().Be(2);
result.Docs.Should().NotBeNull();
result.Docs.Count().Should().Be(2);

foreach (var document in result.Documents)
foreach (var document in result.Docs)
{
document.Index.Should().NotBeNullOrWhiteSpace();
document.Type.Should().NotBeNullOrWhiteSpace();
document.Id.Should().NotBeNullOrWhiteSpace();
document.Version.Should().BeGreaterThan(0);
document.Took.Should().BeGreaterThan(0);

document.TermVectors.Count().Should().Be(1);
document.TermVectors.First().Key.Should().Be("content");
}
Expand Down