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
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@ public abstract class ElasticsearchCorePropertyAttributeBase : ElasticsearchProp

bool? ICoreProperty.Store { get; set; }
IProperties ICoreProperty.Fields { get; set; }
SimilarityOption? ICoreProperty.Similarity { get; set; }
Fields ICoreProperty.CopyTo { get; set; }

public SimilarityOption Similarity { get { return Self.Similarity.GetValueOrDefault(); } set { Self.Similarity = value; } }
Union<SimilarityOption, string> ICoreProperty.Similarity { get; set; }
public string Similarity {
set { Self.Similarity = value; }
get
{
var s = Self.Similarity;
if (s == null) return null;
return s.Match(f => f.GetStringValue(), str => str);
}
}
public bool Store { get { return Self.Store.GetValueOrDefault(); } set { Self.Store = value; } }

protected ElasticsearchCorePropertyAttributeBase(string typeName) : base(typeName)
Expand Down
4 changes: 2 additions & 2 deletions src/Nest/Mapping/Types/CorePropertyBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public interface ICoreProperty : IProperty
IProperties Fields { get; set; }

[JsonProperty("similarity")]
SimilarityOption? Similarity { get; set; }
Union<SimilarityOption, string> Similarity { get; set; }

[JsonProperty("copy_to")]
Fields CopyTo { get; set; }
Expand All @@ -27,7 +27,7 @@ protected CorePropertyBase(TypeName typeName) : base(typeName)

public Fields CopyTo { get; set; }
public IProperties Fields { get; set; }
public SimilarityOption? Similarity { get; set; }
public Union<SimilarityOption, string> Similarity { get; set; }
public bool? Store { get; set; }
}
}
4 changes: 3 additions & 1 deletion src/Nest/Mapping/Types/CorePropertyDescriptorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public abstract class CorePropertyDescriptorBase<TDescriptor, TInterface, T>
where T : class
{
bool? ICoreProperty.Store { get; set; }
SimilarityOption? ICoreProperty.Similarity { get; set; }
Union<SimilarityOption, string> ICoreProperty.Similarity { get; set; }
Fields ICoreProperty.CopyTo { get; set; }
IProperties ICoreProperty.Fields { get; set; }

Expand All @@ -21,6 +21,8 @@ protected CorePropertyDescriptorBase(string type) : base(type) {}

public TDescriptor Similarity(SimilarityOption similarity) => Assign(a => a.Similarity = similarity);

public TDescriptor Similarity(string similarity) => Assign(a => a.Similarity = similarity);

public TDescriptor CopyTo(Func<FieldsDescriptor<T>, IPromise<Fields>> fields) => Assign(a => a.CopyTo = fields?.Invoke(new FieldsDescriptor<T>())?.Value);
}
}
30 changes: 15 additions & 15 deletions src/Tests/ClientConcepts/HighLevel/Mapping/AutoMap.doc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void UsingAutoMap()
{
type = "keyword"
}
},
},
type = "text"
},
hours = new
Expand All @@ -192,7 +192,7 @@ public void UsingAutoMap()
{
type = "keyword"
}
},
},
type = "text"
},
salary = new
Expand All @@ -209,10 +209,10 @@ public void UsingAutoMap()
keyword = new
{
type = "keyword"
}
}
},
type = "text"
}
}
}
},
employee = new
Expand All @@ -236,7 +236,7 @@ public void UsingAutoMap()
{
type = "keyword"
}
},
},
type = "text"
},
hours = new
Expand All @@ -255,7 +255,7 @@ public void UsingAutoMap()
{
type = "keyword"
}
},
},
type = "text"
},
salary = new
Expand Down Expand Up @@ -356,7 +356,7 @@ public void OverridingAutoMappedProperties()
[ElasticsearchType(Name = "company")]
public class CompanyWithAttributes
{
[Keyword(NullValue = "null", Similarity = SimilarityOption.BM25)]
[Keyword(NullValue = "null", Similarity = "BM25")]
public string Name { get; set; }

[Text(Name = "office_hours")]
Expand Down Expand Up @@ -429,7 +429,7 @@ public void UsingAutoMapWithAttributes()
{
type = "keyword"
}
},
},
type = "text"
},
hours = new
Expand All @@ -448,7 +448,7 @@ public void UsingAutoMapWithAttributes()
{
type = "keyword"
}
},
},
type = "text"
},
salary = new
Expand Down Expand Up @@ -503,7 +503,7 @@ public void UsingAutoMapWithAttributes()
{
type = "keyword"
}
},
},
type = "text"
},
hours = new
Expand All @@ -522,7 +522,7 @@ public void UsingAutoMapWithAttributes()
{
type = "keyword"
}
},
},
type = "text"
},
salary = new
Expand Down Expand Up @@ -682,7 +682,7 @@ public void OverridingAutoMappedAttributes()
{
type = "keyword"
}
},
},
type = "text"
},
salary = new
Expand Down Expand Up @@ -785,12 +785,12 @@ public void IgnoringProperties()
keyword = new
{
type = "keyword"
}
}
}
}
}
}
}
}
};

var settings = WithConnectionSettings(s => s
Expand Down Expand Up @@ -960,7 +960,7 @@ public void PutMappingAlsoAdheresToMaxRecursion()
//endhide

/**[float]
* == Applying conventions through the Visitor pattern
* == Applying conventions through the Visitor pattern
* It is also possible to apply a transformation on all or specific properties.
*
* `.AutoMap()` internally implements the https://en.wikipedia.org/wiki/Visitor_pattern[visitor pattern]. The default visitor, `NoopPropertyVisitor`,
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Mapping/Types/Core/Binary/BinaryMappingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class BinaryTest
[Binary(
DocValues = true,
IndexName = "myindex",
Similarity = SimilarityOption.Classic,
Similarity = "classic",
Store = true)]
public string Full { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class BooleanTest
[Boolean(
DocValues = false,
IndexName = "myindex",
Similarity = SimilarityOption.BM25,
Similarity = "BM25",
Index = false,
Store = true)]
public bool Full { get; set; }
Expand Down
30 changes: 15 additions & 15 deletions src/Tests/Mapping/Types/Core/Date/DateMappingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class DateTest
[Date(
DocValues = true,
IndexName = "myindex",
Similarity = SimilarityOption.Classic,
Similarity = "classic",
Store = true,
Index = false,
Boost = 1.2,
Expand All @@ -22,9 +22,9 @@ public class DateTest
[Date]
public DateTime Minimal { get; set; }

public DateTime Inferred { get; set; }
public DateTime Inferred { get; set; }

public DateTimeOffset InferredOffset { get; set; }
public DateTimeOffset InferredOffset { get; set; }
}

public class DateMappingTests : TypeMappingTestBase<DateTest>
Expand Down Expand Up @@ -52,14 +52,14 @@ public class DateMappingTests : TypeMappingTestBase<DateTest>
{
type = "date"
},
inferred = new
{
type = "date"
},
inferredOffset = new
{
type = "date"
}
inferred = new
{
type = "date"
},
inferredOffset = new
{
type = "date"
}
}
};

Expand All @@ -81,11 +81,11 @@ public class DateMappingTests : TypeMappingTestBase<DateTest>
.Date(d => d
.Name(o => o.Minimal)
)
.Date(d => d
.Date(d => d
.Name(o => o.Inferred)
)
.Date(d => d
.Name(o => o.InferredOffset)
);
.Date(d => d
.Name(o => o.InferredOffset)
);
}
}
2 changes: 1 addition & 1 deletion src/Tests/Mapping/Types/Core/Number/NumberMappingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class NumberTest
[Number(
DocValues = true,
IndexName = "myindex",
Similarity = SimilarityOption.Classic,
Similarity = "classic",
Store = true,
Index = false,
Boost = 1.5,
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Mapping/Types/Core/String/StringMappingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class StringTest
NullValue = "na",
PositionIncrementGap = 5,
SearchAnalyzer = "mysearchanalyzer",
Similarity = SimilarityOption.BM25,
Similarity = "BM25",
Store = true,
TermVector = TermVectorOption.WithPositionsOffsets)]
public string Full { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions src/Tests/Mapping/Types/Core/Text/TextMappingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ public class TextTest
PositionIncrementGap = 5,
SearchAnalyzer = "mysearchanalyzer",
SearchQuoteAnalyzer = "mysearchquoteanalyzer",
Similarity = SimilarityOption.Classic,
Similarity = "classic",
Store = true,
Norms = false)]
public string Full { get; set; }

[Text]
public string Minimal { get; set; }

public string Inferred { get; set; }
public string Inferred { get; set; }
}

public class TextMappingTests : TypeMappingTestBase<TextTest>
Expand Down Expand Up @@ -56,7 +56,7 @@ public class TextMappingTests : TypeMappingTestBase<TextTest>
{
type = "text"
},
inferred = new
inferred = new
{
type = "text",
fields = new
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# mode either u (unit test), i (integration test) or m (mixed mode)
mode: i
mode: u
# the elasticsearch version that should be started
# Can be a snapshot version of sonatype or "latest" to get the latest snapshot of sonatype
elasticsearch_version: 5.0.0-alpha5
Expand Down