Open pyoner opened 8 years ago
Yes, we ought to fix that, but it may take a while. It looks like an oversight on our part, probably because a MAPPING apparently can only be added with ALTER (and we tended to focus on the CREATE statements, and the catalogs, but we obviously missed pg_ts_config_map
).
I started to work on this, but it's unclear what would be the minimal best way to handle these mappings.
To start off, I issued the following statements against my test database:
CREATE TEXT SEARCH CONFIGURATION tsc1 (COPY = simple);
ALTER TEXT SEARCH CONFIGURATION tsc1
ALTER MAPPING FOR hword, word WITH english_stem, simple;
The only apparent way to display the mappings in psql
(other than querying the pg_ts_config_map
catalog which only shows OIDs/integers) is to use \dF+ tsc1
, which shows:
Text search configuration "public.tsc1"
Parser: "pg_catalog.default"
Token | Dictionaries
-----------------+---------------------
asciihword | simple
asciiword | simple
email | simple
file | simple
float | simple
host | simple
hword | english_stem,simple
hword_asciipart | simple
hword_numpart | simple
hword_part | simple
int | simple
numhword | simple
numword | simple
sfloat | simple
uint | simple
url | simple
url_path | simple
version | simple
word | english_stem,simple
dbtoyaml
will have to query pg_config_ts_map
and probably output something similar, i.e., a list of tokens and associated dictionaries for each text search configuration. And of course, yamltodb
will have to be changed to read that in.
The pg_dump -s
output is as follows (relevant section only):
CREATE TEXT SEARCH CONFIGURATION tsc1 (
PARSER = pg_catalog."default" );
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR asciiword WITH simple;
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR word WITH english_stem, simple;
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR numword WITH simple;
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR email WITH simple;
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR url WITH simple;
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR host WITH simple;
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR sfloat WITH simple;
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR version WITH simple;
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR hword_numpart WITH simple;
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR hword_part WITH simple;
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR hword_asciipart WITH simple;
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR numhword WITH simple;
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR asciihword WITH simple;
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR hword WITH english_stem, simple;
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR url_path WITH simple;
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR file WITH simple;
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR "float" WITH simple;
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR "int" WITH simple;
ALTER TEXT SEARCH CONFIGURATION tsc1
ADD MAPPING FOR uint WITH simple;
The bottom line is that it is apparently too complicated to reverse engineer what were the original CREATE and ALTER statements, since obviously the "COPY" adds a bunch of rows to pg_ts_config_map
and the ALTER MAPPING changes some of those. yamltodb
will probably have to emulate this pg_dump
behavior.
@pyoner Please read https://pyrseas.wordpress.com/2018/09/12/the-future-of-pyrseas-revisited/ . As mentioned previously, although I started to work on this, I was stuck when I tried to come up with a suitable solution.
I have a sql file:
and dbtoyaml output:
and yamltodb output:
but yamltodb not equal to my sql file.
Can we fix it?