lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Schlegel (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LUCENE-839) WildcardQuery do not find documents if leading and trailing * is used
Date Wed, 21 Mar 2007 08:29:32 GMT

    [ 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: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message