groonga - オープンソースのカラムストア機能付き全文検索エンジン

8.11.5. html_untag

8.11.5.1. 概要

html_untag はHTMLタグをHTMLから除去したテキストを出力します。

html_untagselect で記載されている --output_columns で使います。

8.11.5.2. 構文

html_untag は引数を一つだけとります。 それは column です。

html_untag(column)

8.11.5.3. 使い方

使い方を示すために使うスキーマ定義とサンプルデータは以下の通りです。

サンプルスキーマ:

実行例:

table_create WebClips TABLE_NO_KEY
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create WebClips url COLUMN_SCALAR ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create WebClips content COLUMN_SCALAR ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create WebClips tag COLUMN_VECTOR ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]

サンプルデータ:

実行例:

load --table WebClips
[
{"_key": 1, "url": "http://groonga.org", "tag": ["groonga"], "content": "groonga is <span class='emphasize'>fast</span>"},
{"_key": 2, "url": "http://mroonga.org", "tag": ["mroonga"], "content": "mroonga is <span class=\"emphasize\">fast</span>"},
]
# [[0, 1337566253.89858, 0.000355720520019531], 2]

カラムの本文からHTMLタグを除去する html_untag 関数の簡単な例はこちらです。

実行例:

select WebClips --output_columns "_key, html_untag(content)" --command_version 2
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         2
#       ],
#       [
#         [
#           "html_untag",
#           "null"
#         ]
#       ],
#       [
#         "groonga is fast"
#       ],
#       [
#         "mroonga is fast"
#       ]
#     ]
#   ]
# ]

上記クエリを実行すると、"class" 属性つきの "span" タグが除去されているのがわかります。html_untag 関数を使うのには --command_vesion 2 を指定しなければならないことに注意してください。

8.11.5.4. 引数

必須引数が一つあり、それは column です。

8.11.5.4.1. column

テーブルのカラムを指定します。

8.11.5.5. 戻り値

html_untag はカラムの本文からHTMLタグを除去したテキストを返します。

目次

前のトピックへ

8.11.4. geo_in_rectangle

次のトピックへ

8.11.6. now

このページ