New attribute @fields for snippets that indicates match in other fields.
[idzebra-moved-to-github.git] / include / idzebra / snippet.h
1 /* This file is part of the Zebra server.
2    Copyright (C) 1995-2008 Index Data
3
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18 */
19
20 #ifndef IDZEBRA_SNIPPET_H
21 #define IDZEBRA_SNIPPET_H
22
23 #include <idzebra/util.h>
24
25 YAZ_BEGIN_CDECL
26
27 struct zebra_snippet_word {
28     zint seqno;  /**< sequence number */
29     int ord;     /**< ordinal, i.e. database,field,type */
30     char *term;  /**< term itself */
31     int match;   /**< both part and real match */
32     int mark;    /**< part of snippet */
33     int ws;      /**< white space flag (not indexed material) */
34     struct zebra_snippet_word *next;
35     struct zebra_snippet_word *prev;
36 };
37
38 typedef struct zebra_snippets zebra_snippets;
39 typedef struct zebra_snippet_word zebra_snippet_word;
40
41 YAZ_EXPORT
42 zebra_snippets *zebra_snippets_create(void);
43
44 YAZ_EXPORT
45 void zebra_snippets_destroy(zebra_snippets *l);
46
47 YAZ_EXPORT
48 void zebra_snippets_append(zebra_snippets *l,
49                            zint seqno, int ws, int ord, const char *term);
50
51 YAZ_EXPORT
52 void zebra_snippets_appendn(zebra_snippets *l,
53                             zint seqno, int ws, int ord,
54                             const char *term, size_t term_len);
55
56 YAZ_EXPORT
57 void zebra_snippets_append_match(zebra_snippets *l,
58                                  zint seqno, int ws, int ord,
59                                  const char *term, size_t term_len,
60                                  int match);
61
62 YAZ_EXPORT
63 zebra_snippet_word *zebra_snippets_list(zebra_snippets *l);
64
65 YAZ_EXPORT
66 const zebra_snippet_word *zebra_snippets_constlist(const zebra_snippets *l);
67
68 YAZ_EXPORT
69 void zebra_snippets_log(const zebra_snippets *l, int log_level, int all);
70
71 YAZ_EXPORT
72 zebra_snippets *zebra_snippets_window(const zebra_snippets *doc,
73                                       const zebra_snippets *hit,
74                                       int window_size);
75
76 YAZ_EXPORT
77 void zebra_snippets_ring(zebra_snippets *doc, const zebra_snippets *hit,
78                          int before, int after);
79
80
81 YAZ_EXPORT
82 const struct zebra_snippet_word *zebra_snippets_lookup(
83     const zebra_snippets *doc, const zebra_snippets *hit);
84
85 YAZ_END_CDECL
86
87 #endif
88 /*
89  * Local variables:
90  * c-basic-offset: 4
91  * indent-tabs-mode: nil
92  * End:
93  * vim: shiftwidth=4 tabstop=8 expandtab
94  */
95