lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From java8964 java8964 <>
Subject During the wild card search, will lucene 2.9.0 to convert the search string to lower case?
Date Mon, 01 Feb 2010 16:26:35 GMT

I noticed a strange result from the following test case. For wildcard search, my understanding
is that lucene will NOT use any analyzer on the query string. But as the following simple
code to show, it looks like that lucene will lower case the search query in the wildcard search.
Why? If not, why the following test case show the search hits as one for lower case wildcard
search, but not for the upper case data? My original data is NOT analyzed, so they should
be stored as the original data in the index segment, right?

Lucene version: 2.9.0

JDK version: JDK 1.6.0_17

public class IndexTest1 {
    public static void main(String[] args) {
        try {
            Directory directory = new RAMDirectory();
            IndexWriter writer = new IndexWriter(directory, new StandardAnalyzer(Version.LUCENE_CURRENT),
            Document doc = new Document();
            doc.add(new Field("title", "BBB CCC", Field.Store.YES, Field.Index.NOT_ANALYZED));
            doc = new Document();
            doc.add(new Field("title", "ddd eee", Field.Store.YES, Field.Index.NOT_ANALYZED));


            IndexSearcher searcher = new IndexSearcher(directory, true);
            PerFieldAnalyzerWrapper wrapper = new PerFieldAnalyzerWrapper(new StandardAnalyzer(Version.LUCENE_CURRENT));
            wrapper.addAnalyzer("title", new KeywordAnalyzer());
            Query query = new QueryParser("title",
            System.out.println("hits of title = " +, 100).totalHits);
            query = new QueryParser("title",
            System.out.println("hits of title = " +, 100).totalHits);
        } catch (Exception e) {

The output:
hits of title = 0
hits of title = 1

Hotmail: Trusted email with powerful SPAM protection.
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message