libosmscout 1.1.1
Loading...
Searching...
No Matches
TextSearchIndex.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_TEXTSEARCHINDEX_H
2#define OSMSCOUT_TEXTSEARCHINDEX_H
3
4/*
5 This source is part of the libosmscout library
6 Copyright (C) 2013 Preet Desai
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include <unordered_map>
24
25#include <osmscout/ObjectRef.h>
26
28
29#include <marisa.h>
30
31namespace osmscout
32{
39 {
40 public:
41 static const char* const TEXT_POI_DAT;
42 static const char* const TEXT_LOC_DAT;
43 static const char* const TEXT_REGION_DAT;
44 static const char* const TEXT_OTHER_DAT;
45
46 private:
47 struct TrieInfo
48 {
49 marisa::Trie *trie=nullptr;
50 std::string file;
51 bool isAvail=false;
52 };
53
54 public:
55 using ResultsMap = std::unordered_map<std::string, std::vector<ObjectFileRef> >;
56
57 TextSearchIndex() = default;
58
60
61 bool Load(const std::string &path);
62
63 bool Search(const std::string& query,
64 bool searchPOIs,
65 bool searchLocations,
66 bool searchRegions,
67 bool searchOther,
68 bool transliterate,
69 ResultsMap& results) const;
70
71 private:
72 void splitSearchResult(const std::string& result,
73 std::string& text,
74 ObjectFileRef& ref) const;
75
76
77 uint8_t offsetSizeBytes;
78 std::vector<TrieInfo> tries;
79 };
80}
81
82
83#endif // OSMSCOUT_TEXTSEARCHINDEX_H
#define OSMSCOUT_API
Definition CoreImportExport.h:45
static const char *const TEXT_LOC_DAT
Definition TextSearchIndex.h:42
bool Load(const std::string &path)
static const char *const TEXT_OTHER_DAT
Definition TextSearchIndex.h:44
static const char *const TEXT_POI_DAT
Definition TextSearchIndex.h:41
bool Search(const std::string &query, bool searchPOIs, bool searchLocations, bool searchRegions, bool searchOther, bool transliterate, ResultsMap &results) const
static const char *const TEXT_REGION_DAT
Definition TextSearchIndex.h:43
std::unordered_map< std::string, std::vector< ObjectFileRef > > ResultsMap
Definition TextSearchIndex.h:55
Definition Area.h:39