I have a percolate function written in NEST (c#). I want to enable the highlighting functionality but did not work. The percolator works fine but the highlight did not return anything, and nothing found in NEST documentation. Any help is very appreciated.
var searchResponseDoc = client.Search<PercolatedQuery>(s => s
.Query(q => q
.Percolate(f => f
.Field(p => p.Query)
.DocumentType<Document>() //I have a class called Document
.Document(myDocument))) // myDocument is an object of type Document
.Highlight(h => h
.Fields(f => f
.Field(p => p.Query))
.PreTags("<em>")
.PostTags("</em>")
.FragmentSize(20)));
The Elasticsearch documentation gives a good example of how to use percolate queries with highlighting. Percolate queries with highlighting work a little differently in that the
Fields()
inHighlight()
should be the fields on the document type to be highlighted.For example, given
A percolate query with highlighting might look like
Infer.Field<T>()
is used to get the name of thecontent
field onDocument
asHighlight<T>()
is strongly typed to the response type, in this case,PercolatedQuery
.