1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * phrasequeryfilter.cpp --
|
---|
4 | * Copyright (C) 1999 DigiLib Systems Limited, New Zealand
|
---|
5 | *
|
---|
6 | * PUT COPYRIGHT NOTICE HERE
|
---|
7 | *
|
---|
8 | * $Id: phrasequeryfilter.cpp 328 1999-07-01 04:01:47Z rjmcnab $
|
---|
9 | *
|
---|
10 | *********************************************************************/
|
---|
11 |
|
---|
12 | /*
|
---|
13 | $Log$
|
---|
14 | Revision 1.1 1999/07/01 04:01:47 rjmcnab
|
---|
15 | Initial revision.
|
---|
16 |
|
---|
17 |
|
---|
18 | */
|
---|
19 |
|
---|
20 |
|
---|
21 | #include "phrasequeryfilter.h"
|
---|
22 | #include "queryinfo.h"
|
---|
23 |
|
---|
24 | #include "phrasesearch.h"
|
---|
25 |
|
---|
26 | void do_nother () {
|
---|
27 |
|
---|
28 | }
|
---|
29 |
|
---|
30 |
|
---|
31 | // do aditional query processing
|
---|
32 | void phrasequeryfilterclass::post_process (const queryparamclass &queryparams, const text_t &index,
|
---|
33 | queryresultsclass &queryresults) {
|
---|
34 | // post-process the results if needed
|
---|
35 | if (queryresults.orgterms.size() > 1 && !queryresults.docs.empty()) {
|
---|
36 | // get the long version of the index
|
---|
37 | text_t longindex;
|
---|
38 | indexmap.to2from (index, longindex);
|
---|
39 |
|
---|
40 | // process each of the matched documents
|
---|
41 | vector<docresultclass> phrasematchdocs;
|
---|
42 | vector<docresultclass> otherdocs;
|
---|
43 | vector<docresultclass>::iterator docs_here = queryresults.docs.begin();
|
---|
44 | vector<docresultclass>::iterator docs_end = queryresults.docs.end();
|
---|
45 | while (docs_here != docs_end) {
|
---|
46 | if ((*docs_here).num_query_terms_matched == queryresults.orgterms.size() &&
|
---|
47 | OID_phrase_search (*mgsearchptr, *gdbmptr, queryparams.search_index,
|
---|
48 | longindex, queryparams.collection, queryresults.orgterms,
|
---|
49 | (*docs_here).docnum)) {
|
---|
50 | (*docs_here).query_phrase_match = true;
|
---|
51 | phrasematchdocs.push_back (*docs_here);
|
---|
52 | } else {
|
---|
53 | otherdocs.push_back (*docs_here);
|
---|
54 | }
|
---|
55 |
|
---|
56 | docs_here++;
|
---|
57 | }
|
---|
58 |
|
---|
59 | // reorder the documents if necessary
|
---|
60 | if (!phrasematchdocs.empty()) {
|
---|
61 | queryresults.docs = phrasematchdocs;
|
---|
62 | queryresults.docs.insert (queryresults.docs.end(), otherdocs.begin(), otherdocs.end());
|
---|
63 | }
|
---|
64 | }
|
---|
65 | }
|
---|