[ 
https://issues.apache.org/jira/browse/LUCENE-839?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12482671
 ] 

Michael Schlegel commented on LUCENE-839:
-----------------------------------------

I use release 2.1.0.

Here is an example to demonstrate the problem:

public class WildcardTest
{
    
    public static void main(String[] args) throws Exception
    {
        Analyzer analyzer = new StandardAnalyzer();
        
        RAMDirectory indexStore = getIndexStore("fulltext", new 
String[]{"Forschungsgebiet", "business"}, analyzer);
        
        IndexSearcher searcher = new IndexSearcher(indexStore);
        
        QueryParser parser = new QueryParser( "fulltext", analyzer );
        parser.setAllowLeadingWildcard(true);
        Query query1 = parser.parse("fulltext:*usines*");
        Query query2 = parser.parse("fulltext:*usines?");
        
        
        Hits result = searcher.search(query1);
        System.out.println( "Query '" + query1.toString() + "' found: " + 
result.length() + " documents !");

        result = searcher.search(query2);
        System.out.println( "Query '" + query2.toString() + "' found: " + 
result.length() + " documents !");

        
        searcher.close();
        indexStore.close();
    }
    
    private static RAMDirectory getIndexStore(String field, String[] contents, 
Analyzer p_Analyzer)
    throws IOException
    {
        RAMDirectory indexStore = new RAMDirectory();
        IndexWriter writer = new IndexWriter(indexStore, p_Analyzer, true);
        for (int i = 0; i < contents.length; ++i)
        {
            Document doc = new Document();
            doc.add(new Field(field, contents[i], Field.Store.YES, 
Field.Index.TOKENIZED));
            writer.addDocument(doc);
        }
        writer.optimize();
        writer.close();
        
        return indexStore;
    }
}

Output:
Query 'fulltext:*usines*' found: 0 documents !
Query 'fulltext:*usines?' found: 1 documents !






                


> WildcardQuery do not find documents if leading and trailing * is used
> ---------------------------------------------------------------------
>
>                 Key: LUCENE-839
>                 URL: https://issues.apache.org/jira/browse/LUCENE-839
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 1.9, 2.0.0, 2.1
>            Reporter: Michael Schlegel
>         Assigned To: Doron Cohen
>
> I indexed a document which contains the word "business".
> If i use query "business" then document will be found.
> If i use query "busines*" then document will be found.
> If i use query "*usiness" then document will be found.
> If i use query "*usines?" then document will be found.
> If i use query "?usines?" then document will be found.
> But if i use query "*usines*" then document will not be found.
> if i use query "*usi*nes*" then document will be found.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to