Switch to unified view

a/src/query/xadump.cpp b/src/query/xadump.cpp
1
#ifndef lint
1
#ifndef lint
2
static char rcsid[] = "@(#$Id: xadump.cpp,v 1.10 2006-01-28 10:23:55 dockes Exp $ (C) 2004 J.F.Dockes";
2
static char rcsid[] = "@(#$Id: xadump.cpp,v 1.11 2006-09-19 14:18:57 dockes Exp $ (C) 2004 J.F.Dockes";
3
#endif
3
#endif
4
/*
4
/*
5
 *   This program is free software; you can redistribute it and/or modify
5
 *   This program is free software; you can redistribute it and/or modify
6
 *   it under the terms of the GNU General Public License as published by
6
 *   it under the terms of the GNU General Public License as published by
7
 *   the Free Software Foundation; either version 2 of the License, or
7
 *   the Free Software Foundation; either version 2 of the License, or
...
...
41
    " -t term -E  : term existence test\n"
41
    " -t term -E  : term existence test\n"
42
    " -t term -F  : retrieve term frequency data\n"
42
    " -t term -F  : retrieve term frequency data\n"
43
    " -t term -P  : retrieve postings for term\n"
43
    " -t term -P  : retrieve postings for term\n"
44
    " -i docid -T : term list for doc docid\n"
44
    " -i docid -T : term list for doc docid\n"
45
    " -T          : list all terms\n"
45
    " -T          : list all terms\n"
46
    " -s          : special mode to dump recoll stem db\n"
46
    "  \n\n"
47
    "  \n\n"
47
    ;
48
    ;
48
49
49
static void
50
static void
50
Usage(void)
51
Usage(void)
...
...
62
#define OPT_t     0x20
63
#define OPT_t     0x20
63
#define OPT_P     0x40
64
#define OPT_P     0x40
64
#define OPT_F     0x80
65
#define OPT_F     0x80
65
#define OPT_E     0x100
66
#define OPT_E     0x100
66
#define OPT_b     0x200
67
#define OPT_b     0x200
68
#define OPT_s     0x400
67
69
68
Xapian::Database *db;
70
Xapian::Database *db;
69
71
70
static void cleanup()
72
static void cleanup()
71
{
73
{
...
...
98
        switch (*(*argv)++) {
100
        switch (*(*argv)++) {
99
        case 'D':   op_flags |= OPT_D; break;
101
        case 'D':   op_flags |= OPT_D; break;
100
        case 'E':   op_flags |= OPT_E; break;
102
        case 'E':   op_flags |= OPT_E; break;
101
        case 'F':   op_flags |= OPT_F; break;
103
        case 'F':   op_flags |= OPT_F; break;
102
        case 'P':   op_flags |= OPT_P; break;
104
        case 'P':   op_flags |= OPT_P; break;
105
      case 's':   op_flags |= OPT_s; break;
103
        case 'T':   op_flags |= OPT_T; break;
106
        case 'T':   op_flags |= OPT_T; break;
104
        case 'b':   op_flags |= OPT_b; break;
107
        case 'b':   op_flags |= OPT_b; break;
105
        case 'd':   op_flags |= OPT_d; if (argc < 2)  Usage();
108
        case 'd':   op_flags |= OPT_d; if (argc < 2)  Usage();
106
        dbdir = *(++argv);
109
        dbdir = *(++argv);
107
        argc--; 
110
        argc--; 
...
...
143
        
146
        
144
    if (op_flags & OPT_T) {
147
    if (op_flags & OPT_T) {
145
        Xapian::TermIterator term;
148
        Xapian::TermIterator term;
146
        string printable;
149
        string printable;
147
        if (op_flags & OPT_i) {
150
        if (op_flags & OPT_i) {
148
        for (term = db->termlist_begin(docid);
151
        for (term = db->termlist_begin(docid); 
149
             term != db->termlist_end(docid);term++) {
152
             term != db->termlist_end(docid);term++) {
150
            cout << "[" << *term << "]" << endl;
153
            cout << "[" << *term << "]" << endl;
151
        }
154
        }
152
        } else {
155
        } else {
153
        for (term = db->allterms_begin(); 
156
        for (term = db->allterms_begin(); 
154
             term != db->allterms_end();term++) {
157
             term != db->allterms_end();term++) {
155
            cout << "utf8[" << *term << "]" << endl;
158
            cout << "[" << *term << "]" << endl;
159
      }
160
      }
161
  } else if (op_flags & OPT_s) {
162
      for (unsigned int docid = 1;
163
       docid < db->get_lastdocid(); docid++) {
164
      // cout << docid << ": ";
165
      Xapian::TermIterator term;
166
      for (term = db->termlist_begin(docid); 
167
           term != db->termlist_end(docid);term++) {
168
          cout << *term << " ";
169
          Xapian::Document doc = db->get_document(docid);
170
          string data = doc.get_data();
171
          cout << data;
156
        }
172
        }
157
        }
173
        }
158
    } else if (op_flags & OPT_D) {
174
    } else if (op_flags & OPT_D) {
159
        Xapian::Document doc = db->get_document(docid);
175
        Xapian::Document doc = db->get_document(docid);
160
        string data = doc.get_data();
176
        string data = doc.get_data();