Skip to content

Commit

Permalink
don't allocate if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Shazwazza committed Nov 30, 2023
1 parent 10fbef3 commit 03d208b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(MSBuildProjectName)' != 'Examine.Web.Demo' AND '$(MSBuildProjectName)' != 'Examine.Test'">
<TargetFrameworks>net6.0;netstandard2.1;netstandard2.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>

</Project>
7 changes: 5 additions & 2 deletions src/Examine.Lucene/Search/CustomMultiFieldQueryParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ namespace Examine.Lucene.Search
/// </summary>
public class CustomMultiFieldQueryParser : MultiFieldQueryParser
{
private QueryParser _keywordAnalyzerQueryParser;

public CustomMultiFieldQueryParser(LuceneVersion matchVersion, string[] fields, Analyzer analyzer)
: base(matchVersion, fields, analyzer)
=> SearchableFields = fields;
{
SearchableFields = fields;
}

// NOTE: Query parsers are not thread safe so we need to create a new instance here
internal QueryParser KeywordAnalyzerQueryParser { get; } = new QueryParser(LuceneInfo.CurrentVersion, string.Empty, new KeywordAnalyzer());
internal QueryParser KeywordAnalyzerQueryParser => _keywordAnalyzerQueryParser ??= new QueryParser(LuceneInfo.CurrentVersion, string.Empty, new KeywordAnalyzer());

public string[] SearchableFields { get; }

Expand Down

0 comments on commit 03d208b

Please sign in to comment.