Collection<ScoreDocPtr> search() { // create PhraseQuery "term1 term2" and search PhraseQueryPtr pq = newLucene<PhraseQuery>(); pq->add(newLucene<Term>(field, term1)); pq->add(newLucene<Term>(field, term2)); return searcher->search(pq, FilterPtr(), 1000)->scoreDocs; }
PhraseQueryPtr makePhraseQuery(const String& terms) { PhraseQueryPtr query = newLucene<PhraseQuery>(); Collection<String> tokens = StringUtils::split(terms, L" +"); for (int32_t i = 0; i < tokens.size(); ++i) query->add(newLucene<Term>(L"f", tokens[i])); return query; }