Skip to content

Commit d1e5346

Browse files
committed
Support Percolate query WiP
1 parent 3d8787b commit d1e5346

File tree

91 files changed

+973
-276
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+973
-276
lines changed

src/Elasticsearch.Net/Domain/IPropertyMapping.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,5 @@ public class PropertyMapping : IPropertyMapping
3333
/// <pre>- When Indexing this type do not serialize whatever this value hold</pre>
3434
/// </summary>
3535
public bool Ignore { get; set; }
36-
3736
}
3837
}

src/Nest/CommonAbstractions/Infer/Indices/Indices.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,4 @@ public override int GetHashCode()
8686
);
8787
}
8888
}
89-
}
89+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using System.Reflection;
3+
using Newtonsoft.Json;
4+
5+
namespace Nest
6+
{
7+
[AttributeUsage(AttributeTargets.Property)]
8+
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
9+
public abstract class ElasticsearchCorePropertyAttributeBase : ElasticsearchPropertyAttributeBase, ICoreProperty
10+
{
11+
private ICoreProperty Self => this;
12+
13+
PropertyName IProperty.Name { get; set; }
14+
TypeName IProperty.Type { get; set; }
15+
string IProperty.IndexName { get; set; }
16+
bool? ICoreProperty.Store { get; set; }
17+
bool? ICoreProperty.DocValues { get; set; }
18+
IProperties ICoreProperty.Fields { get; set; }
19+
SimilarityOption? ICoreProperty.Similarity { get; set; }
20+
Fields ICoreProperty.CopyTo { get; set; }
21+
22+
public bool DocValues { get { return Self.DocValues.GetValueOrDefault(); } set { Self.DocValues = value; } }
23+
public SimilarityOption Similarity { get { return Self.Similarity.GetValueOrDefault(); } set { Self.Similarity = value; } }
24+
public bool Store { get { return Self.Store.GetValueOrDefault(); } set { Self.Store = value; } }
25+
26+
protected ElasticsearchCorePropertyAttributeBase(string typeName) : base(typeName)
27+
{
28+
}
29+
30+
protected ElasticsearchCorePropertyAttributeBase(Type type) : base(type)
31+
{
32+
}
33+
34+
public new static ElasticsearchCorePropertyAttributeBase From(MemberInfo memberInfo)
35+
{
36+
return memberInfo.GetCustomAttribute<ElasticsearchCorePropertyAttributeBase>(true);
37+
}
38+
}
39+
}

src/Nest/Mapping/AttributeBased/ElasticsearchPropertyAttributeBase.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,10 @@ public abstract class ElasticsearchPropertyAttributeBase : Attribute, IProperty,
1515
PropertyName IProperty.Name { get; set; }
1616
TypeName IProperty.Type { get; set; }
1717
string IProperty.IndexName { get; set; }
18-
bool? IProperty.Store { get; set; }
19-
bool? IProperty.DocValues { get; set; }
20-
IProperties IProperty.Fields { get; set; }
21-
SimilarityOption? IProperty.Similarity { get; set; }
22-
Fields IProperty.CopyTo { get; set; }
2318

2419
public string Name { get; set; }
2520
public bool Ignore { get; set; }
26-
public bool DocValues { get { return Self.DocValues.GetValueOrDefault(); } set { Self.DocValues = value; } }
2721
public string IndexName { get { return Self.IndexName; } set { Self.IndexName = value; } }
28-
public SimilarityOption Similarity { get { return Self.Similarity.GetValueOrDefault(); } set { Self.Similarity = value; } }
29-
public bool Store { get { return Self.Store.GetValueOrDefault(); } set { Self.Store = value; } }
3022

3123
protected ElasticsearchPropertyAttributeBase(string typeName)
3224
{
@@ -43,4 +35,4 @@ public static ElasticsearchPropertyAttributeBase From(MemberInfo memberInfo)
4335
return memberInfo.GetCustomAttribute<ElasticsearchPropertyAttributeBase>(true);
4436
}
4537
}
46-
}
38+
}

src/Nest/Mapping/AttributeBased/ElasticsearchTypeAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Nest
77
{
8-
[AttributeUsage(System.AttributeTargets.Class, AllowMultiple = false)]
8+
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
99
public class ElasticsearchTypeAttribute : Attribute
1010
{
1111
private static readonly ConcurrentDictionary<Type, ElasticsearchTypeAttribute> CachedTypeLookups =
@@ -27,4 +27,4 @@ public static ElasticsearchTypeAttribute From(Type type)
2727
return attr;
2828
}
2929
}
30-
}
30+
}

src/Nest/Mapping/DynamicTemplate/SingleMapping.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,8 @@ public IProperty Murmur3Hash(Func<Murmur3HashPropertyDescriptor<T>, IMurmur3Hash
5353

5454
public IProperty TokenCount(Func<TokenCountPropertyDescriptor<T>, ITokenCountProperty> selector) =>
5555
selector?.Invoke(new TokenCountPropertyDescriptor<T>());
56+
57+
public IProperty Percolator(Func<PercolatorPropertyDescriptor<T>, IPercolatorProperty> selector) =>
58+
selector?.Invoke(new PercolatorPropertyDescriptor<T>());
5659
}
5760
}

src/Nest/Mapping/Types/Complex/Object/ObjectAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Nest
44
{
5-
public class ObjectAttribute : ElasticsearchPropertyAttributeBase, IObjectProperty
5+
public class ObjectAttribute : ElasticsearchCorePropertyAttributeBase, IObjectProperty
66
{
77
IObjectProperty Self => this;
88

@@ -20,5 +20,5 @@ public class ObjectAttribute : ElasticsearchPropertyAttributeBase, IObjectProper
2020
public ObjectAttribute() : base("object") { }
2121
protected ObjectAttribute(string typeName) : base(typeName) { }
2222
protected ObjectAttribute(Type type) : base(type) { }
23-
}
23+
}
2424
}

src/Nest/Mapping/Types/Complex/Object/ObjectProperty.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Nest
66
{
77
[JsonObject(MemberSerialization.OptIn)]
8-
public interface IObjectProperty : IProperty
8+
public interface IObjectProperty : ICoreProperty
99
{
1010
[JsonProperty("dynamic")]
1111
DynamicMapping? Dynamic { get; set; }
@@ -23,7 +23,7 @@ public interface IObjectProperty : IProperty
2323
IProperties Properties { get; set; }
2424
}
2525

26-
public class ObjectProperty : PropertyBase, IObjectProperty
26+
public class ObjectProperty : CorePropertyBase, IObjectProperty
2727
{
2828
public ObjectProperty() : base("object") { }
2929

@@ -44,7 +44,7 @@ public class ObjectTypeDescriptor<TParent, TChild>
4444
}
4545

4646
public abstract class ObjectPropertyDescriptorBase<TDescriptor, TInterface, TParent, TChild>
47-
: PropertyDescriptorBase<TDescriptor, TInterface, TParent>, IObjectProperty
47+
: CorePropertyDescriptorBase<TDescriptor, TInterface, TParent>, IObjectProperty
4848
where TDescriptor : ObjectPropertyDescriptorBase<TDescriptor, TInterface, TParent, TChild>, TInterface
4949
where TInterface : class, IObjectProperty
5050
where TParent : class
@@ -58,7 +58,7 @@ public abstract class ObjectPropertyDescriptorBase<TDescriptor, TInterface, TPar
5858
string IObjectProperty.Path { get; set; }
5959
IProperties IObjectProperty.Properties { get; set; }
6060

61-
public ObjectPropertyDescriptorBase() : this("object") { }
61+
protected ObjectPropertyDescriptorBase() : this("object") { }
6262

6363
protected ObjectPropertyDescriptorBase(string type) : base(type)
6464
{
@@ -88,4 +88,4 @@ public TDescriptor AutoMap(IPropertyVisitor visitor = null, int maxRecursion = 0
8888

8989
public TDescriptor AutoMap(int maxRecursion) => AutoMap(null, maxRecursion);
9090
}
91-
}
91+
}

src/Nest/Mapping/Types/Core/Binary/BinaryAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Nest
44
{
55
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
6-
public class BinaryAttribute : ElasticsearchPropertyAttributeBase, IBinaryProperty
6+
public class BinaryAttribute : ElasticsearchCorePropertyAttributeBase, IBinaryProperty
77
{
88
public BinaryAttribute() : base("binary") { }
9-
}
9+
}
1010
}

src/Nest/Mapping/Types/Core/Binary/BinaryProperty.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
namespace Nest
44
{
55
[JsonObject(MemberSerialization.OptIn)]
6-
public interface IBinaryProperty : IProperty
6+
public interface IBinaryProperty : ICoreProperty
77
{
88
}
99

10-
public class BinaryProperty : PropertyBase, IBinaryProperty
10+
public class BinaryProperty : CorePropertyBase, IBinaryProperty
1111
{
1212
public BinaryProperty() : base("binary") { }
1313
}
1414

15-
public class BinaryPropertyDescriptor<T>
16-
: PropertyDescriptorBase<BinaryPropertyDescriptor<T>, IBinaryProperty, T>, IBinaryProperty
15+
public class BinaryPropertyDescriptor<T>
16+
: CorePropertyDescriptorBase<BinaryPropertyDescriptor<T>, IBinaryProperty, T>, IBinaryProperty
1717
where T : class
1818
{
1919
public BinaryPropertyDescriptor() : base("binary") { }
2020
}
21-
}
21+
}

src/Nest/Mapping/Types/Core/Boolean/BooleanAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Nest
22
{
3-
public class BooleanAttribute : ElasticsearchPropertyAttributeBase, IBooleanProperty
3+
public class BooleanAttribute : ElasticsearchCorePropertyAttributeBase, IBooleanProperty
44
{
55
IBooleanProperty Self => this;
66

src/Nest/Mapping/Types/Core/Boolean/BooleanProperty.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Nest
55
{
66

77
[JsonObject(MemberSerialization.OptIn)]
8-
public interface IBooleanProperty : IProperty
8+
public interface IBooleanProperty : ICoreProperty
99
{
1010
[JsonProperty("index")]
1111
bool? Index { get; set; }
@@ -20,7 +20,7 @@ public interface IBooleanProperty : IProperty
2020
INumericFielddata Fielddata { get; set; }
2121
}
2222

23-
public class BooleanProperty : PropertyBase, IBooleanProperty
23+
public class BooleanProperty : CorePropertyBase, IBooleanProperty
2424
{
2525
public BooleanProperty() : base("boolean") { }
2626

@@ -31,7 +31,7 @@ public BooleanProperty() : base("boolean") { }
3131
}
3232

3333
public class BooleanPropertyDescriptor<T>
34-
: PropertyDescriptorBase<BooleanPropertyDescriptor<T>, IBooleanProperty, T>, IBooleanProperty
34+
: CorePropertyDescriptorBase<BooleanPropertyDescriptor<T>, IBooleanProperty, T>, IBooleanProperty
3535
where T : class
3636
{
3737
double? IBooleanProperty.Boost { get; set; }

src/Nest/Mapping/Types/Core/Date/DateAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Nest
44
{
5-
public class DateAttribute : ElasticsearchPropertyAttributeBase, IDateProperty
5+
public class DateAttribute : ElasticsearchCorePropertyAttributeBase, IDateProperty
66
{
77
IDateProperty Self => this;
88

src/Nest/Mapping/Types/Core/Date/DateProperty.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Nest
55
{
66
[JsonObject(MemberSerialization.OptIn)]
7-
public interface IDateProperty : IProperty
7+
public interface IDateProperty : ICoreProperty
88
{
99
[JsonProperty("index")]
1010
bool? Index { get; set; }
@@ -34,7 +34,7 @@ public interface IDateProperty : IProperty
3434
INumericFielddata Fielddata { get; set; }
3535
}
3636

37-
public class DateProperty : PropertyBase, IDateProperty
37+
public class DateProperty : CorePropertyBase, IDateProperty
3838
{
3939
public DateProperty() : base("date") { }
4040

@@ -50,7 +50,7 @@ public DateProperty() : base("date") { }
5050
}
5151

5252
public class DatePropertyDescriptor<T>
53-
: PropertyDescriptorBase<DatePropertyDescriptor<T>, IDateProperty, T>, IDateProperty
53+
: CorePropertyDescriptorBase<DatePropertyDescriptor<T>, IDateProperty, T>, IDateProperty
5454
where T : class
5555
{
5656
bool? IDateProperty.Index { get; set; }

src/Nest/Mapping/Types/Core/Keyword/KeywordAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Nest
88
{
9-
public class KeywordAttribute : ElasticsearchPropertyAttributeBase, IKeywordProperty
9+
public class KeywordAttribute : ElasticsearchCorePropertyAttributeBase, IKeywordProperty
1010
{
1111
IKeywordProperty Self => this;
1212

src/Nest/Mapping/Types/Core/Keyword/KeywordProperty.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Nest
99
{
1010
[JsonObject(MemberSerialization.OptIn)]
11-
public interface IKeywordProperty : IProperty
11+
public interface IKeywordProperty : ICoreProperty
1212
{
1313
[JsonProperty("boost")]
1414
double? Boost { get; set; }
@@ -38,7 +38,7 @@ public interface IKeywordProperty : IProperty
3838
string SearchAnalyzer { get; set; }
3939
}
4040

41-
public class KeywordProperty : PropertyBase, IKeywordProperty
41+
public class KeywordProperty : CorePropertyBase, IKeywordProperty
4242
{
4343
public KeywordProperty() : base("keyword") { }
4444

@@ -54,7 +54,7 @@ public KeywordProperty() : base("keyword") { }
5454
}
5555

5656
public class KeywordPropertyDescriptor<T>
57-
: PropertyDescriptorBase<KeywordPropertyDescriptor<T>, IKeywordProperty, T>, IKeywordProperty
57+
: CorePropertyDescriptorBase<KeywordPropertyDescriptor<T>, IKeywordProperty, T>, IKeywordProperty
5858
where T : class
5959
{
6060
double? IKeywordProperty.Boost { get; set; }

src/Nest/Mapping/Types/Core/Number/NumberAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/// Maps a property as a number type. If no type is specified,
55
/// the default type is float (single precision floating point).
66
/// </summary>
7-
public class NumberAttribute : ElasticsearchPropertyAttributeBase, INumberProperty
7+
public class NumberAttribute : ElasticsearchCorePropertyAttributeBase, INumberProperty
88
{
99
INumberProperty Self => this;
1010

src/Nest/Mapping/Types/Core/Number/NumberProperty.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Nest
55
{
66
[JsonObject(MemberSerialization.OptIn)]
7-
public interface INumberProperty : IProperty
7+
public interface INumberProperty : ICoreProperty
88
{
99
[JsonProperty("index")]
1010
bool? Index { get; set; }
@@ -31,7 +31,7 @@ public interface INumberProperty : IProperty
3131
INumericFielddata Fielddata { get; set; }
3232
}
3333

34-
public class NumberProperty : PropertyBase, INumberProperty
34+
public class NumberProperty : CorePropertyBase, INumberProperty
3535
{
3636
public NumberProperty() : base(NumberType.Float.GetStringValue()) { }
3737
public NumberProperty(NumberType type) : base(type.GetStringValue()) { }
@@ -48,7 +48,7 @@ protected NumberProperty(string type) : base(type) { }
4848
}
4949

5050
public abstract class NumberPropertyDescriptorBase<TDescriptor, TInterface, T>
51-
: PropertyDescriptorBase<TDescriptor, TInterface, T>, INumberProperty
51+
: CorePropertyDescriptorBase<TDescriptor, TInterface, T>, INumberProperty
5252
where TDescriptor : NumberPropertyDescriptorBase<TDescriptor, TInterface, T>, TInterface
5353
where TInterface : class, INumberProperty
5454
where T : class
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Nest
2+
{
3+
public class PercolatorAttribute : ElasticsearchPropertyAttributeBase, IPercolatorProperty
4+
{
5+
public PercolatorAttribute() : base("percolator") { }
6+
}
7+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Newtonsoft.Json;
7+
8+
namespace Nest
9+
{
10+
[JsonObject(MemberSerialization.OptIn)]
11+
public interface IPercolatorProperty : IProperty
12+
{
13+
}
14+
15+
public class PercolatorProperty : PropertyBase, IPercolatorProperty
16+
{
17+
public PercolatorProperty() : base("percolator") { }
18+
}
19+
20+
public class PercolatorPropertyDescriptor<T>
21+
: PropertyDescriptorBase<PercolatorPropertyDescriptor<T>, IPercolatorProperty, T>, IPercolatorProperty
22+
where T : class
23+
{
24+
public PercolatorPropertyDescriptor() : base("percolator") { }
25+
}
26+
}

src/Nest/Mapping/Types/Core/String/StringAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Nest
22
{
3-
public class StringAttribute : ElasticsearchPropertyAttributeBase, IStringProperty
3+
public class StringAttribute : ElasticsearchCorePropertyAttributeBase, IStringProperty
44
{
55
IStringProperty Self => this;
66

0 commit comments

Comments
 (0)