Get list of names/sql code for analizers

Hello guys,

Could someone show me how I can get list of all custom analysers (list of names, sql code) that was created like this example:

CREATE ANALYZER myanalyzer (
  TOKENIZER whitespace,
  TOKEN_FILTERS (
    lowercase,
    kstem
  ),
  CHAR_FILTERS (
    html_strip
  )
);

Maybe CrateDB has some construction like show create table <table_name> but for analyzers.

Thanks!

I don’t think we have a SHOW CREATE ANALYZER functionality yet, but you can see the created anlayzers in the information_schema.routines table.

SELECT *
FROM information_schema.routines
WHERE routine_type = 'ANALYZER'
    and routine_definition is NOT null;
2 Likes

Thank you, it was helpfully. But where I can read about all system tables such as

information_schema.routines information_schema.columns information_schema.tables

etc.
Thanks.

1 Like

Documentation for information_schema is here: Information schema — CrateDB: Reference

My analyzer looks like this:

create ANALYZER bankruptcies_ngram_and_synonym (
TOKENIZER CustomTokenizer with (type='ngram', min_gram=2, max_gram=2, token_chars=['letter']),
TOKEN_FILTERS (my_synonyms WITH (type='synonym', synonyms_path='synonyms.txt'), lowercase, kstem)
);

But this query:

SELECT *
FROM information_schema.routines
WHERE routine_type = 'ANALYZER'
    and routine_definition is NOT null;

Return next:

{"filter":["lowercase","kstem","bankruptcies_ngram_and_synonym_my_synonyms"],"tokenizer":"bankruptcies_ngram_and_synonym_customtokenizer","type":"custom"}

But how I could see real SQL code for this analyzer?
Thanks!

Hi @Valeriy_Dzhura

That is not really possible yet. You could use a query like the following …

SELECT routine_name, routine_definition, routine_schema, routine_type	
FROM information_schema.routines
WHERE routine_name LIKE 'bankruptcies_ngram_and_synonym%';

… to also get back the custom tokeniser and filter. But be aware, that for e.g the synonyms filter no more information is currently exposed.