You are currently browsing legacy 4.1 version of documentation. Click here to switch to the newest 5.1 version.
Migration: How to Migrate Highlighting from 3.x
Highlighting functionality has been merged into RQL . Following minor and cosmetic changes have been introduced.
Namespaces
3.x
using Raven.Client;
using Raven.Client.Document;
4.0
using Raven.Client.Documents;
using Raven.Client.Documents.Queries.Highlighting;
Example I
3.x
SearchItem[] results = session
.Query<SearchItem>("ContentSearchIndex")
.Customize(x => x.Highlight("Text", 128, 1, out FieldHighlightings highlightings))
.Search(x => x.Text, "raven")
.ToArray();
4.0
List<SearchItem> results = session
.Query<SearchItem, ContentSearchIndex>()
.Highlight(x => x.Text, 128, 1, out Highlightings highlightings)
.Search(x => x.Text, "raven")
.ToList();
List<SearchItem> results = session
.Advanced
.DocumentQuery<SearchItem, ContentSearchIndex>()
.Highlight(x => x.Text, 128, 1, out Highlightings highlightings)
.Search(x => x.Text, "raven")
.ToList();
Example II
3.x
SearchItem[] results = session
.Query<SearchItem>("ContentSearchIndex")
.Customize(x => x.Highlight("Text", 128, 1, out FieldHighlightings highlightings))
.SetHighlighterTags("**", "**")
.Search(x => x.Text, "raven")
.ToArray();
4.0
List<SearchItem> results = session
.Query<SearchItem, ContentSearchIndex>()
.Highlight(x => x.Text, 128, 1, new HighlightingOptions
{
PreTags = new[] { "**" },
PostTags = new[] { "**" }
}, out Highlightings highlightings)
.Search(x => x.Text, "raven")
.ToList();
List<SearchItem> results = session
.Advanced
.DocumentQuery<SearchItem, ContentSearchIndex>()
.Highlight(x => x.Text, 128, 1, new HighlightingOptions
{
PreTags = new[] { "**" },
PostTags = new[] { "**" }
}, out Highlightings highlightings)
.Search(x => x.Text, "raven")
.ToList();
Please enable JavaScript to view the comments powered by Disqus.