Skip to content

Support doc_values attributes on numeric and string mappings and in ElasticProperty attributes #644

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 3 commits into from
May 7, 2014
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 @@ -21,9 +21,11 @@ public class ElasticPropertyAttribute : Attribute, IElasticPropertyAttribute
public string Analyzer { get; set; }
public string IndexAnalyzer { get; set; }
public string SearchAnalyzer { get; set; }
public string SortAnalyzer { get; set; }
public string SortAnalyzer { get; set; }
public string NullValue { get; set; }
public string Similarity { get; set; }
public string Similarity { get; set; }

public bool DocValues { get; set; }

public bool OmitNorms { get; set; }
public bool OmitTermFrequencyAndPositions { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
public interface IElasticPropertyAttribute
{
bool AddSortField { get; set; }
bool OptOut { get; set; }
string Name { get; set; }

Expand All @@ -22,7 +22,9 @@ public interface IElasticPropertyAttribute
bool OmitNorms { get; set; }
bool OmitTermFrequencyAndPositions { get; set; }
bool IncludeInAll { get; set; }
bool Store { get; set; }
bool Store { get; set; }

bool DocValues { get; set; }

string Similarity { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public NumberMappingDescriptor<T> PrecisionStep(int precisionStep)
return this;
}

public NumberMappingDescriptor<T> DocValues(bool docValues = true)
{
this._Mapping.DocValues = docValues;
return this;
}

public NumberMappingDescriptor<T> IncludeInAll(bool includeInAll = true)
{
this._Mapping.IncludeInAll = includeInAll;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public StringMappingDescriptor<T> SearchAnalyzer(string searchAnalyzer)
this._Mapping.SearchAnalyzer = searchAnalyzer;
return this;
}
public StringMappingDescriptor<T> DocValues(bool docValues = true)
{
this._Mapping.DocValues = docValues;
return this;
}
public StringMappingDescriptor<T> IncludeInAll(bool includeInAll = true)
{
this._Mapping.IncludeInAll = includeInAll;
Expand Down
3 changes: 3 additions & 0 deletions src/Nest/Domain/Mapping/Types/NumberMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public class NumberMapping : IElasticType, IElasticCoreType
[JsonProperty("null_value")]
public double? NullValue { get; set; }

[JsonProperty("doc_values")]
public bool? DocValues { get; set; }

[JsonProperty("include_in_all")]
public bool? IncludeInAll { get; set; }

Expand Down
3 changes: 3 additions & 0 deletions src/Nest/Domain/Mapping/Types/StringMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public class StringMapping : IElasticType, IElasticCoreType
[JsonProperty("search_analyzer")]
public string SearchAnalyzer { get; set; }

[JsonProperty("doc_values")]
public bool? DocValues { get; set; }

[JsonProperty("include_in_all")]
public bool? IncludeInAll { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ public void VisitBaseAttribute(IElasticPropertyAttribute att) {
this._jsonWriter.WritePropertyName("omit_norms");
this._jsonWriter.WriteValue("true");
}
if (att.DocValues)
{
this._jsonWriter.WritePropertyName("doc_values");
this._jsonWriter.WriteValue("true");
}
if (att.OmitTermFrequencyAndPositions)
{
this._jsonWriter.WritePropertyName("omit_term_freq_and_positions");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"docvaluesfoo": {
"properties": {
"id": {
"type": "integer"
},
"value": {
"type": "integer",
"doc_values": true
}
}
}
}
25 changes: 25 additions & 0 deletions src/Tests/Nest.Tests.Unit/Core/Map/Properties/PropertiesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,31 @@ public void GeoShapeProperty()
)
);
this.JsonEquals(result.ConnectionStatus.Request, MethodInfo.GetCurrentMethod());
}

public class DocValuesFoo
{
public int Id { get; set; }
[ElasticProperty(DocValues=true)]
public int Value { get; set; }
}

[Test]
public void DocValuesProperty()
{
var result = this._client.Map<DocValuesFoo>(m => m.MapFromAttributes());
this.JsonEquals(result.ConnectionStatus.Request, MethodInfo.GetCurrentMethod());

var result2 = this._client.Map<DocValuesFoo>(m => m
.Properties(props => props
.Number(nmd => nmd
.Name("id")
.Type(NumberType.integer))
.Number(nmd => nmd
.Name("value")
.Type(NumberType.integer)
.DocValues())));
this.JsonEquals(result2.ConnectionStatus.Request, MethodInfo.GetCurrentMethod());
}

}
Expand Down
1,743 changes: 872 additions & 871 deletions src/Tests/Nest.Tests.Unit/Nest.Tests.Unit.csproj

Large diffs are not rendered by default.