FileDocCategorySizeDatePackage
TestNot.javaAPI DocApache Lucene 1.91739Mon Feb 20 09:19:32 GMT 2006org.apache.lucene.search

TestNot

public class TestNot extends TestCase
Similarity unit test.
author
Doug Cutting
version
$Revision: 150497 $

Fields Summary
Constructors Summary
public TestNot(String name)

    super(name);
  
Methods Summary
public voidtestNot()

    RAMDirectory store = new RAMDirectory();
    IndexWriter writer = new IndexWriter(store, new SimpleAnalyzer(), true);

    Document d1 = new Document();
    d1.add(new Field("field", "a b", Field.Store.YES, Field.Index.TOKENIZED));

    writer.addDocument(d1);
    writer.optimize();
    writer.close();

    Searcher searcher = new IndexSearcher(store);
    Query query = QueryParser.parse("a NOT b", "field", new SimpleAnalyzer());
    //System.out.println(query);
    Hits hits = searcher.search(query);
    assertEquals(0, hits.length());