java-user@lucene.apache.org
[Top] [All Lists]

Lucene fields not analyzed

Subject: Lucene fields not analyzed
From: Rohit Banga
Date: Tue, 9 Feb 2010 12:56:45 +0530
Hello

i have a field that stores names of people. i have used the NOT_ANALYZED
parameter to index the names.

this is what happens during indexing

    doc.add(new Field("name", "\"" + name + "\"", Field.Store.YES,
Field.Index.NOT_ANALYZED));



when i search it, i create a query parser using standardanalyzer and append
~0.5 to the search query.

the problem is that if the indexed name is "Mr. Kumar", my search does not
work for "Mr. Kumar" while it does work for "Mr.Kumar" (without the space).

// searching code
        File index_directory = new File(INDEX_DIR_PATH);
        IndexReader reader =
IndexReader.open(FSDirectory.open(index_directory), true);
        Searcher searcher = new IndexSearcher(reader);

        Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);

        QueryParser parser = new QueryParser(Version.LUCENE_CURRENT, "name",
analyzer);

        Query query;
        query = parser.parse(text + "~0.5");

how to make it work?

Rohit Banga
<Prev in Thread] Current Thread [Next in Thread>