diff --git a/README.md b/README.md index e5351b1..04523d9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Umbraco Look (Alpha) -Umbraco Examine Lucene indexer and searcher with support for text match highlighting and geospatial queries. +Extends Umbraco Examine adding support for: text match highlighting, geospatial querying and tag faceting. [The NuGet Package](https://www.nuget.org/packages/Our.Umbraco.Look) installs a single assembly _Our.Umbraco.Look.dll_ with dependencies on: @@ -91,8 +91,7 @@ var lookQuery = new LookQuery() TextQuery = new TextQuery() { SearchText = "some text to search for", - HighlightFragments = 2, // highlight text containing the search term twice should be returned - HighlightSeparator = " ... ", // text to inject between any search term matches + GetHighlight = true, // return highlight extract from the text field containing the search text GetText = true // raw text field should be returned (potentially a large document) }, diff --git a/src/Our.Umbraco.Look.sln b/src/Our.Umbraco.Look.sln index 53c55b9..a56671e 100644 --- a/src/Our.Umbraco.Look.sln +++ b/src/Our.Umbraco.Look.sln @@ -13,7 +13,6 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{453855DC-542E-404A-9378-D53153A59C8F}" ProjectSection(SolutionItems) = preProject ..\build\Package.nuspec = ..\build\Package.nuspec - ..\build\Package.xml = ..\build\Package.xml EndProjectSection EndProject Global diff --git a/src/Our.Umbraco.Look/Models/TextQuery.cs b/src/Our.Umbraco.Look/Models/TextQuery.cs index 33ef92a..4fcd8fc 100644 --- a/src/Our.Umbraco.Look/Models/TextQuery.cs +++ b/src/Our.Umbraco.Look/Models/TextQuery.cs @@ -13,14 +13,9 @@ public class TextQuery public float Fuzzyness { get; set; } = 0; /// - /// The max number of fragments to show, 0 = highlighting disabled + /// When true (and SearchText provided), a hightlight extract containing the search text will be returned /// - public int HighlightFragments { get; set; } = 0; - - /// - /// Text rendered between any highlight fragments - /// - public string HighlightSeparator { get; set; } = "..."; + public bool GetHighlight { get; set; } = false; /// /// Flag to indicate whether the source text field should be returned diff --git a/src/Our.Umbraco.Look/Services/LookSearchService.cs b/src/Our.Umbraco.Look/Services/LookSearchService.cs index 3599fc4..1598750 100644 --- a/src/Our.Umbraco.Look/Services/LookSearchService.cs +++ b/src/Our.Umbraco.Look/Services/LookSearchService.cs @@ -250,7 +250,7 @@ public static LookResult Query(LookQuery lookQuery) } // setup the getHightlight func if required - if (lookQuery.TextQuery.HighlightFragments > 0 && !string.IsNullOrWhiteSpace(lookQuery.TextQuery.SearchText)) + if (lookQuery.TextQuery != null && lookQuery.TextQuery.GetHighlight && !string.IsNullOrWhiteSpace(lookQuery.TextQuery.SearchText)) { var queryParser = new QueryParser(Lucene.Net.Util.Version.LUCENE_29, LookConstants.TextField, LookService.Analyzer); @@ -268,8 +268,8 @@ public static LookResult Query(LookQuery lookQuery) var highlight = highlighter.GetBestFragments( tokenStream, x, - lookQuery.TextQuery.HighlightFragments, // max number of fragments - lookQuery.TextQuery.HighlightSeparator); // fragment separator + 1, // max number of fragments + "..."); return new HtmlString(highlight); };