import Since from '@components/shared/Since.astro' import RailroadDiagram from '@components/RailroadDiagram.astro' import Tabs from '@components/Tabs/Tabs.astro' import TabItem from '@components/Tabs/TabItem.astro'
ALTER ANALYZER statement
The ALTER ANALYZER statement can be used to modify an existing defined analyzer.
Statement syntax
SurrealQL Syntax
ALTER ANALYZER [ IF EXISTS ] @name
[ FUNCTION fn::@function | DROP FUNCTION ]
[ TOKENIZERS @tokenizer, ... | DROP TOKENIZERS ]
[ FILTERS @filter, ... | DROP FILTERS ]
[ COMMENT @string | DROP COMMENT ]
export const alterAst = { type: "Diagram", padding: [10, 20, 10, 20], children: [ { type: "Sequence", children: [ { type: "Terminal", text: "ALTER ANALYZER" }, { type: "Optional", child: { type: "Sequence", children: [ { type: "Terminal", text: "IF" }, { type: "Terminal", text: "EXISTS" }, ], }, }, { type: "Terminal", text: "@name" }, { type: "Optional", child: { type: "Choice", index: 0, children: [ { type: "Sequence", children: [ { type: "Terminal", text: "FUNCTION" }, { type: "Terminal", text: "@function" }, ], }, { type: "Sequence", children: [ { type: "Terminal", text: "DROP" }, { type: "Terminal", text: "FUNCTION" }, ], }, ], }, }, { type: "Optional", child: { type: "Choice", index: 0, children: [ { type: "Sequence", children: [ { type: "Terminal", text: "TOKENIZERS" }, { type: "NonTerminal", text: "@tokenizer" }, { type: "ZeroOrMore", child: { type: "Sequence", children: [ { type: "Terminal", text: "," }, { type: "NonTerminal", text: "@tokenizer" }, ], }, repeat: { type: "Skip" }, }, ], }, { type: "Sequence", children: [ { type: "Terminal", text: "DROP" }, { type: "Terminal", text: "TOKENIZERS" }, ], }, ], }, }, { type: "Optional", child: { type: "Choice", index: 0, children: [ { type: "Sequence", children: [ { type: "Terminal", text: "FILTERS" }, { type: "NonTerminal", text: "@filter" }, { type: "ZeroOrMore", child: { type: "Sequence", children: [ { type: "Terminal", text: "," }, { type: "NonTerminal", text: "@filter" }, ], }, repeat: { type: "Skip" }, }, ], }, { type: "Sequence", children: [ { type: "Terminal", text: "DROP" }, { type: "Terminal", text: "FILTERS" }, ], }, ], }, }, { type: "Optional", child: { type: "Choice", index: 0, children: [ { type: "Sequence", children: [ { type: "Terminal", text: "COMMENT" }, { type: "Terminal", text: "@string" }, ], }, { type: "Sequence", children: [ { type: "Terminal", text: "DROP" }, { type: "Terminal", text: "COMMENT" }, ], }, ], }, }, ], }, ], };
Example usage
-- Define an analyzer
DEFINE ANALYZER example_edgengram TOKENIZERS class FILTERS edgengram(1,3);
-- Shorten the edgengram
ALTER ANALYZER example_edgengram FILTERS edgengram(1,2);
-- Check the output
search::analyze("example_edgengram", "Apple banana!!");
Output
[
'A',
'Ap',
'b',
'ba',
'!',
'!!'
]