Debian Codegraph @

doc/source/reference/extractors.md

raw symbols SCIP
1 <!-- groonga-command -->
2 <!-- database: extractors -->
3
4 # Extractors
5
6 ## Summary
7
8 ```{versionadded} 16.0.3
9
10 ```
11
12 ```{note}
13 This is an experimental feature. Currently, this feature is still not stable.
14 ```
15
16 Groonga has extractor module that extracts plain text or values from
17 structured data such as HTML and JSON. It is used before tokenizing
18 and indexing a value. For example, {doc}`extractors/extractor_html`
19 extracts only the text content from HTML by removing tags, so that
20 markup such as `<p>` isn't indexed as a token.
21
22 Extractor module can be added as a plugin. You can customize value
23 extraction by registering your extractor plugins to Groonga.
24
25 An extractor module is attached to a table. The table is normally a
26 lexicon for an index. A table can have zero or more extractor
27 modules. You can attach extractor modules to a table by the
28 {ref}`table-create-extractors` option in
29 {doc}`/reference/commands/table_create`.
30
31 Here is an example `table_create` that uses the
32 {doc}`extractors/extractor_html` extractor module:
33
34 <!-- groonga-command -->
35
36 ```{include} ../example/reference/extractors/example_table_create.md
37 table_create Terms TABLE_PAT_KEY ShortText --extractors ExtractorHTML
38 ```
39
40 When extractors are set to a lexicon, they are applied automatically
41 when an index of the lexicon is updated. The extracted value is
42 tokenized and indexed instead of the original value. The original
43 value is still stored as-is in its data column. So you can search
44 against the extracted content while keeping the original structured
45 data.
46
47 If a table has multiple extractors, they are applied in order. The
48 output of an extractor is passed to the next extractor as its
49 input. This is useful when you need to combine extractors. For
50 example, you can extract a string from JSON by
51 {doc}`extractors/extractor_json` and then remove HTML tags in the
52 string by {doc}`extractors/extractor_html`.
53
54 You can use the {doc}`/reference/commands/extract` command to check
55 how extractors process a value. The {doc}`/reference/commands/extract`
56 command applies the specified extractors to the given value and
57 returns the extracted value. It doesn't need a table:
58
59 <!-- groonga-command -->
60
61 ```{include} ../example/reference/extractors/example_extract.md
62 extract \
63 --extractors 'ExtractorHTML' \
64 --value "<html><body>He&lt;ll&gt;o</body></html>"
65 ```
66
67 The `extract` command is useful to confirm the result of extractors
68 before you attach them to a lexicon.
69
70 ## Built-in extractors
71
72 Here is a list of built-in extractors:
73
74 ```{toctree}
75 :maxdepth: 1
76 :glob:
77
78 extractors/*
79 ```
80
81 ## See also
82
83 - {doc}`/reference/commands/extract`
84 - {doc}`/reference/commands/table_create`