Skip to content

Commit

Permalink
fix #199 count() overload with indices and types, does not append _co…
Browse files Browse the repository at this point in the history
…unt suffix
  • Loading branch information
Mpdreamz committed Apr 1, 2013
1 parent dffc1d9 commit 9beab98
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
20 changes: 19 additions & 1 deletion src/Nest.Tests.Integration/Search/CountTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using Nest.Tests.MockData;
using Nest.Tests.MockData.Domain;
using NUnit.Framework;
using FluentAssertions;
using Nest.Resolvers;

namespace Nest.Tests.Integration.Search
{
Expand Down Expand Up @@ -42,9 +44,25 @@ public void SimpleQueryWithIndexAndTypeCount()
.Value(this._LookFor.ToLower())
)
);
Assert.True(countResults.Count > 0);
countResults.Count.Should().Be(3);
}

[Test]
public void SimpleQueryWithIndicesCount()
{
//does a match_all on the default specified index
var index = ElasticsearchConfiguration.DefaultIndex;
var indices = new[] { index, index + "_clone" };
var types = new[] { new TypeNameResolver().GetTypeNameFor<ElasticSearchProject>() };
var countResults = this._client.Count<ElasticSearchProject>(indices, types, q => q
.Fuzzy(fq => fq
.OnField(f => f.Followers.First().FirstName)
.Value(this._LookFor.ToLower())
)
);
countResults.IsValid.Should().Be(true);
countResults.Count.Should().Be(3);
}

[Test]
public void SimpleTypedCount()
Expand Down
6 changes: 4 additions & 2 deletions src/Nest/Resolvers/PathResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public string CreateIndexTypePath(string index, string type, string suffix = nul
type.ThrowIfNullOrEmpty("type");
index = Uri.EscapeDataString(index);
type = Uri.EscapeDataString(type);

if (suffix != null)
return "{0}/{1}/{2}".F(index, type, this.NormalizeSuffix(suffix));

return "{0}/{1}/".F(index, type);
}

Expand All @@ -109,7 +109,9 @@ public string CreateIndexTypePath(IEnumerable<string> indices, IEnumerable<strin
indices.ThrowIfEmpty("indices");
types.ThrowIfEmpty("types");
var index = string.Join(",", indices);
var type = string.Join(",", types);
var type = string.Join(",", types);
if (suffix != null)
return "{0}/{1}/{2}".F(Uri.EscapeDataString(index), Uri.EscapeDataString(type), this.NormalizeSuffix(suffix));

return "{0}/{1}/".F(Uri.EscapeDataString(index), Uri.EscapeDataString(type));
}
Expand Down

0 comments on commit 9beab98

Please sign in to comment.