lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Taylor <paul_t...@fastmail.fm>
Subject Re: StandardFilter not handling dots as exptected ?
Date Thu, 06 Aug 2009 14:45:57 GMT
Erick Erickson wrote:
> I don't see anything obvious in the code.
>
> Are you using the same analzer at query time as at index time?
Yes, I do I have created a testcase now, that fails


import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Hits;
import org.apache.lucene.queryParser.QueryParser;
import junit.framework.TestCase;

public class RESTest extends TestCase {
    public void testMatchAcronymns() throws Exception {
        Analyzer analyzer = new StandardUnaccentAnalyzer();
        RAMDirectory dir = new RAMDirectory();
        IndexWriter writer = new IndexWriter(dir, analyzer, true, 
IndexWriter.MaxFieldLength.LIMITED);
        Document doc = new Document();
        doc.add(new Field("name", "R.E.S.", Field.Store.YES, 
Field.Index.ANALYZED));
        writer.addDocument(doc);
        writer.close();

        IndexSearcher searcher = new IndexSearcher(dir);
        Query q = new QueryParser("name", analyzer).parse("R.E.S");
        System.out.println(q.toString());
        Hits hits = searcher.search(q);
        assertEquals(1, hits.length());
    }
}
>
> I'd also get a copy of Luke and examine your index to see what
> is actually getting put in it, and query.toString might help.
>
Query to string returns
name:r.e.s

Paul

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message