Skip to content

Added overload to type filter #287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2013
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
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,8 @@ public void TermsTest()
public void TypeTest()
{
this.DoConditionlessFilter(f => f.Type(string.Empty));
this.DoConditionlessFilter(f => f.Type(null));
this.DoConditionlessFilter(f => f.Type((string)null));
}



}
}
3 changes: 2 additions & 1 deletion src/Nest/DSL/Filter/TypeFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nest.Resolvers;
using Newtonsoft.Json;

namespace Nest
Expand All @@ -18,6 +19,6 @@ internal override bool IsConditionless
}

[JsonProperty(PropertyName = "value")]
public string Value { get; set;}
public TypeNameMarker Value { get; set; }
}
}
17 changes: 17 additions & 0 deletions src/Nest/DSL/FilterDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,23 @@ public BaseFilter Type(string type)
this.TypeFilter = filter;
return new FilterDescriptor<T>() { TypeFilter = filter };
}

/// <summary>
/// Filters documents matching the provided document / mapping type.
/// Note, this filter can work even when the _type field is not indexed
/// (using the _uid field).
/// </summary>
public BaseFilter Type(Type type)
{
var filter = new TypeFilter { Value = type };
if (filter.IsConditionless)
return CreateConditionlessFilterDescriptor("filter", filter);

this.SetCacheAndName(filter);
this.TypeFilter = filter;
return new FilterDescriptor<T>() { TypeFilter = filter };
}

/// <summary>
/// A filter that matches on all documents.
/// </summary>
Expand Down