I'm not sure what I'm doing wrong.  I can see my fields in the index file,
but my query/search returns no hits.

Here is my index creation code:

lucene::analysis::SimpleAnalyzer* analyzer;

int main(int argc, char** argv)
{
    analyzer = new lucene::analysis::SimpleAnalyzer();
    Directory* indexDir = FSDirectory::getDirectory("../Index");

    IndexWriter* w = new IndexWriter(indexDir, analyzer, true, true);

    int config = Field::STORE_YES && Field::INDEX_TOKENIZED;

    Field* field;
    Document* doc;

    doc = new Document();

    field = new Field(L"president", L"Nixon", config);
    doc->clear();
    doc->add(*field);
    w->addDocument(doc);

    field = new Field(L"president", L"Obama", config);
    doc->clear();
    doc->add(*field);
    w->addDocument(doc);

    field = new Field(L"president", L"Clinton", config);
    doc->clear();
    doc->add(*field);
    w->addDocument(doc);

    w->close();

    indexDir->close();
}

Here is my query code:


int main(int argc, char** argv)
{

    IndexReader* reader = IndexReader::open("../Index");

    lucene::analysis::SimpleAnalyzer* analyzer =
        new lucene::analysis::SimpleAnalyzer();

    IndexReader* newreader = reader->reopen();
    if ( newreader != reader )
    {
        _CLLDELETE(reader);
        reader = newreader;
    }
    IndexSearcher searcher(reader);


    Query* query = QueryParser::parse(L"Nixon*",
        L"president", analyzer);
    Hits* hits = searcher.search(query);
    cout << "Total hits: " << hits->length() << endl;
}


I get no hits on this. I've tried to make my experiment as simple as
possible, but I get nothing.  Is the query formed wrong?

Thanks for any help.

Regards,
Mark
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
CLucene-developers mailing list
CLucene-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/clucene-developers

Reply via email to