11#include <osl/file.hxx>
12#include <osl/thread.hxx>
19 OUString ustrSystemPath;
20 osl::File::getSystemPathFromFileURL(indexDir, ustrSystemPath);
25 std::vector<OUString> &rDocuments, std::vector<float> &rScores) {
27 lucene::index::IndexReader *reader = lucene::index::IndexReader::open(
d_indexDir.getStr());
28 lucene::search::IndexSearcher searcher(reader);
30 const TCHAR* field = captionOnly ? L
"caption" : L
"content";
32 bool isWildcard = queryStr[queryStr.getLength() - 1] == L
'*';
34 lucene::search::Query *pQuery;
36 pQuery = _CLNEW lucene::search::WildcardQuery(_CLNEW lucene::index::Term(field, aQueryStr.data()));
38 pQuery = _CLNEW lucene::search::TermQuery(_CLNEW lucene::index::Term(field, aQueryStr.data()));
40 lucene::search::Hits *hits = searcher.search(pQuery);
41 for (
size_t i = 0;
i < hits->length(); ++
i) {
42 lucene::document::Document &doc = hits->doc(
i);
43 wchar_t const *path = doc.get(L
"path");
45 rScores.push_back(hits->score(
i));
OUString TCHARArrayToOUString(TCHAR const *str)
std::vector< TCHAR > OUStringToTCHARVec(OUString const &rStr)
void query(OUString const &queryStr, bool captionOnly, std::vector< OUString > &rDocuments, std::vector< float > &rScores)
Query the index for a certain query string.
HelpSearch(OUString const &indexDir)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)