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

   **Description:**
   I am using StandardAnyalzer to retrieve the stored data using wildcards. 
This works fine for almost all cases but when I use a wildcard with a 
restricted character like Hyphen, the matching data is not retrieved.
   
   **Steps to reproduce:**
   You can run the following code to see this behavior:
   
   ```
   public static void Test()
           {
               // Use an in-memory index.
               var indexDirectory = new RAMDirectory();
               
               Analyzer analyzer = new 
StandardAnalyzer(LuceneVersion.LUCENE_48);
               
               using (var writer = new IndexWriter(indexDirectory, new 
IndexWriterConfig(LuceneVersion.LUCENE_48, analyzer)))
               {
                   var document = new Document
                   {
                       new TextField("content", "This is just some text", 
Field.Store.YES),
                       new TextField("cataloguenumber", "DF-TESTER", 
Field.Store.YES)
                   };
                   writer.AddDocument(document);
               }
               var parser = new MultiFieldQueryParser(
                   LuceneVersion.LUCENE_48,
                   new[] { "cataloguenumber", "content" },
                   analyzer)
               {
                   AllowLeadingWildcard = true
               };
   
               var directoryReader = DirectoryReader.Open(indexDirectory);
               var searcher = new IndexSearcher(directoryReader);
               
               DoSearch("DF-TES", parser, searcher); // Returns the matching 
document
               
               DoSearch("DF-TES*", parser, searcher); // Does not return 
anything
           }
   
           private static void DoSearch(string queryString, 
MultiFieldQueryParser parser, IndexSearcher searcher)
           {
               var query = parser.Parse(queryString);
   
               var docs = searcher.Search(query, 10);
   
               foreach (var scoreDoc in docs.ScoreDocs)
               {
                   var searchHit = searcher.Doc(scoreDoc.Doc);
                   var cataloguenumber = 
searchHit.GetValues("cataloguenumber").FirstOrDefault();
                   var content = 
searchHit.GetValues("content").FirstOrDefault();
                   Console.WriteLine($"Found object: {cataloguenumber} 
{content}");
               }
           }
   ```
   When I run the above code, method `DoSearch` with query string: `DF-TES` 
returns the valid result, however with `DF-TES*` this does not return anything. 
It looks like the query is not rewritten correctly when I am adding a Wildcard 
and hence leading to this behavior.
   
   **Expected behavior**
   On running the above example with wildcards we should get the matching 
result set.
   
   Let me know if any more details are needed or if I haven't understood this 
correctly.
   


-- 
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