FileDocCategorySizeDatePackage
TestNot.javaAPI DocApache Lucene 1.91763Mon Feb 20 09:20:30 GMT 2006org.apache.lucene.search

TestNot

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

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(Field.Text("field", "a b"));

    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());