jooooel opened a new issue, #907:
URL: https://github.com/apache/lucenenet/issues/907

   ### Is there an existing issue for this?
   
   - [X] I have searched the existing issues
   
   ### Describe the bug
   
   I'm not 100% sure if this is a bug or if it's me not knowing enough about 
how Lucene.NET works, but I get a `NullReferenceException` when trying to parse 
a query that contains a phrase.
   
   I hope the steps to reproduce below are enough, please let me know otherwise.
   
   ### Expected Behavior
   
   That the query can be parsed and part of it will be a `PhraseQuery`.
   
   ### Steps To Reproduce
   
   In `csproj`:
   ```
   <PackageReference Include="Lucene.Net.QueryParser" Version="4.8.0-beta00016" 
/>
   ```
   
   `Program.cs`:
   ```
   using Lucene.Net.Analysis.Core;
   using Lucene.Net.Util;
   
   using var analyzer = new WhitespaceAnalyzer(LuceneVersion.LUCENE_48);
   var parser = new 
Lucene.Net.QueryParsers.Classic.QueryParser(LuceneVersion.LUCENE_48, null, 
analyzer);
   
   var query = """
               (Happy OR "I'm very happy") AND hello
               """;
   var parsedQuery = parser.Parse(query);
   ```
   
   ### Exceptions (if any)
   
   ```
   Unhandled exception. System.NullReferenceException: Object reference not set 
to an instance of an object.
      at Lucene.Net.Search.PhraseQuery.Add(Term term, Int32 position)
      at Lucene.Net.Util.QueryBuilder.CreateFieldQuery(Analyzer analyzer, Occur 
operator, String field, String queryText, Boolean quoted, Int32 phraseSlop)
      at Lucene.Net.QueryParsers.Classic.QueryParserBase.NewFieldQuery(Analyzer 
analyzer, String field, String queryText, Boolean quoted)
      at Lucene.Net.QueryParsers.Classic.QueryParserBase.GetFieldQuery(String 
field, String queryText, Boolean quoted)
      at Lucene.Net.QueryParsers.Classic.QueryParserBase.GetFieldQuery(String 
field, String queryText, Int32 slop)
      at 
Lucene.Net.QueryParsers.Classic.QueryParserBase.HandleQuotedTerm(String qfield, 
Token term, Token fuzzySlop)
      at Lucene.Net.QueryParsers.Classic.QueryParser.Term(String field)
      at Lucene.Net.QueryParsers.Classic.QueryParser.Clause(String field)
      at Lucene.Net.QueryParsers.Classic.QueryParser.Query(String field)
      at Lucene.Net.QueryParsers.Classic.QueryParser.Clause(String field)
      at Lucene.Net.QueryParsers.Classic.QueryParser.Query(String field)
      at Lucene.Net.QueryParsers.Classic.QueryParser.TopLevelQuery(String field)
      at Lucene.Net.QueryParsers.Classic.QueryParserBase.Parse(String query)
      at Program.<Main>$(String[] args) in ...Program.cs:line 13
   ```
   
   ### Lucene.NET Version
   
   4.8.0-beta00016
   
   ### .NET Version
   
   8.0.100
   
   ### Operating System
   
   MacOS Sonoma 14.2.1
   
   ### Anything else?
   
   Macbook Pro M1 (ARM)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@lucenenet.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to