Skip to content

Added HighlightQuery to HighlightFieldDescriptor #1553

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
Sep 14, 2015
Merged
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
25 changes: 18 additions & 7 deletions src/Nest/DSL/Search/HighlightFieldDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ public interface IHighlightField

[JsonProperty("matched_fields")]
IEnumerable<PropertyPathMarker> MatchedFields { get; set; }
}

public class HighlightField : IHighlightField
[JsonProperty("highlight_query")]
IQueryContainer HighlightQuery { get; set; }
}

public class HighlightField : IHighlightField
{
public PropertyPathMarker Field { get; set; }
public IEnumerable<string> PreTags { get; set; }
Expand All @@ -77,7 +80,8 @@ public class HighlightField : IHighlightField
public string Type { get; set; }
public bool? ForceSource { get; set; }
public IEnumerable<PropertyPathMarker> MatchedFields { get; set; }
}
public IQueryContainer HighlightQuery { get; set; }
}

public class HighlightFieldDescriptor<T> : IHighlightField where T : class
{
Expand Down Expand Up @@ -113,9 +117,11 @@ public class HighlightFieldDescriptor<T> : IHighlightField where T : class

bool? IHighlightField.ForceSource { get; set; }

IEnumerable<PropertyPathMarker> IHighlightField.MatchedFields { get; set; }

public HighlightFieldDescriptor<T> OnField(string field)
IEnumerable<PropertyPathMarker> IHighlightField.MatchedFields { get; set; }

IQueryContainer IHighlightField.HighlightQuery { get; set; }

public HighlightFieldDescriptor<T> OnField(string field)
{
Self.Field = field;
return this;
Expand Down Expand Up @@ -224,5 +230,10 @@ public HighlightFieldDescriptor<T> MatchedFields(params Expression<Func<T, objec
Self.MatchedFields = objectPaths.Select(f => (PropertyPathMarker)f);
return this;
}
}
public HighlightFieldDescriptor<T> HighlightQuery(Func<QueryDescriptor<T>, QueryContainer> query)
{
Self.HighlightQuery = query(new QueryDescriptor<T>());
return this;
}
}
}