1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * mgsearch.h --
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * PUT COPYRIGHT NOTICE HERE
|
---|
7 | *
|
---|
8 | * $Id: mgsearch.h 226 1999-04-06 22:20:35Z rjmcnab $
|
---|
9 | *
|
---|
10 | *********************************************************************/
|
---|
11 |
|
---|
12 |
|
---|
13 | #ifndef MGSEARCH_H
|
---|
14 | #define MGSEARCH_H
|
---|
15 |
|
---|
16 |
|
---|
17 | #include "text_t.h"
|
---|
18 | #include "querycache.h"
|
---|
19 |
|
---|
20 | #define RESULTCACHESIZE 10
|
---|
21 | #define MAXNUMDOCS 500
|
---|
22 | #define MAXNUMTERMS 100
|
---|
23 |
|
---|
24 | // a few useful functions for dealing with dir indexes (indexes as they
|
---|
25 | // appear within the index directory) and real indexes (indexes as they
|
---|
26 | // appear within the collect.cfg file) and mappings between them.
|
---|
27 |
|
---|
28 | // all these functions can go when we don't need src/library any more
|
---|
29 |
|
---|
30 | void getdirindexparts (const text_tarray &indexmap, const text_tarray &subcollectionmap,
|
---|
31 | const text_tarray &languagemap, const text_t &dirindex,
|
---|
32 | text_t &index, text_t &subcollection, text_t &language);
|
---|
33 | void getrealindexparts (const text_tarray &indexmap, const text_tarray &subcollectionmap,
|
---|
34 | const text_tarray &languagemap, const text_t &realindex,
|
---|
35 | text_t &index, text_t &subcollection, text_t &language);
|
---|
36 | void getrealdir (const text_t &map, text_t &realpart, text_t &dirpart);
|
---|
37 | void getrealdirindex (const text_t &indexmap, const text_t &subcollectionmap,
|
---|
38 | const text_t &languagemap, text_t &realindex,
|
---|
39 | text_t &dirindex);
|
---|
40 | bool isdirindex (const text_tarray &indexmap, const text_t &dirindex);
|
---|
41 | bool isrealindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,
|
---|
42 | const text_tarray &languagemap, const text_t &realindex);
|
---|
43 | text_t dir2realindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,
|
---|
44 | const text_tarray &languagemap, const text_t &dirindex);
|
---|
45 | text_t real2dirindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,
|
---|
46 | const text_tarray &languagemap, const text_t &realindex);
|
---|
47 | text_t real2macroindex (const text_t &realindex);
|
---|
48 | bool isdoclevelindex (const text_t &realindex);
|
---|
49 | text_t getdoclevelindex (const text_tarray &indexmap);
|
---|
50 |
|
---|
51 |
|
---|
52 |
|
---|
53 | class mgsearchclass {
|
---|
54 | public:
|
---|
55 | mgsearchclass ();
|
---|
56 | virtual ~mgsearchclass ();
|
---|
57 |
|
---|
58 | // the index directory must be set before any searching
|
---|
59 | // is done
|
---|
60 | void setcollectdir (const text_t &thecollectdir);
|
---|
61 |
|
---|
62 | // the search results are returned in queryresults
|
---|
63 | // search returns 'true' if it was able to do a search
|
---|
64 | bool search(const queryparamclass &queryparams,
|
---|
65 | queryresultsclass &queryresults);
|
---|
66 |
|
---|
67 | // the document text for 'docnum' is placed in 'output'
|
---|
68 | // docTargetDocument returns 'true' if it was able to
|
---|
69 | // try to get a document
|
---|
70 | // collection is needed to see if an index from the
|
---|
71 | // collection is loaded. If no index has been loaded
|
---|
72 | // defaultindex is needed to load one
|
---|
73 | bool docTargetDocument(const text_t &defaultindex,
|
---|
74 | const text_t &collection,
|
---|
75 | int docnum,
|
---|
76 | text_t &output);
|
---|
77 |
|
---|
78 | protected:
|
---|
79 | querycache *cache;
|
---|
80 | text_t collectdir; // the collection directory
|
---|
81 |
|
---|
82 | void setsearchmode (const queryparamclass &queryparams);
|
---|
83 | void submitquery (const queryparamclass &queryparams);
|
---|
84 | void getresults (queryresultsclass &queryresults);
|
---|
85 |
|
---|
86 | virtual void extractquoted (text_t &ttquerystring, text_t &ttquotedquery);
|
---|
87 | virtual void filterquery (text_t &ttquerystring);
|
---|
88 | };
|
---|
89 |
|
---|
90 |
|
---|
91 | #endif
|
---|