29.1. 建表语句
CREATE FOREIGN TABLE copyfield_test(
hashstr text,
i1 int,
i2 int,
txt1 text OPTIONS(token 'ik'),
txt2 text,
txt3 text,
copyall_1 text[] OPTIONS(token 'w4',store 'ids'),
copyall_2 text[] OPTIONS(token 'ik',store 'ids')
) SERVER lxdb options(
copyfield1 'equals@txt2|i1|i2 dest@txt3',
copyfield2 'indexof@all dest@copyall_1 ',
copyfield3 'rangeof@1~3 dest@copyall_2 '
);
INSERT INTO copyfield_test(hashstr,i1, i2, txt1,txt2) VALUES ('1111',0, 20, 'txt 中国 aaa aaaa 1283711 www.163.com ', 'myn@163.com 1708837171')
汇聚列 检索
select copyall_2 from copyfield_test where copyall_2[0] like 'aaa 中国';
select copyall_1 from copyfield_test where copyall_1[0] like 'myn@163.com';
29.2. 其他用法
汇聚1:汇聚字段名称以cs开头的数据(cs1),withfield@true表示含有原始字段的名称
copyfield 'indexof@cs dest@copy_string1 withfield@true',
汇聚2:汇聚字段名称以cs开头的字段的数据(cs1),不含原始字段的名称
copyfield 'indexof@cs dest@copy_string2',
汇聚3:汇聚字段’sc1’中的数据(copy_string1在汇聚1中已做汇聚,可以继续对其添加汇聚数据,不会对之前的内容造成覆盖),withfield@true表示含有原始字段的名称
copyfield 'equals@sc1 dest@copy_string1 withfield@true',
汇聚4:汇聚’cwc4_1’中的数据,不含原始字段的名称
copyfield 'equals@cwc4_1 dest@copy_txt',
汇聚5:汇聚所有字段中的数据,withfield@true表示含有原始字段的名称
copyfield 'indexof@all dest@copy_all withfield@true',
汇聚6:汇聚第2~3个字段中的数据(sc1、cwc4_1),withfield@true表示含有原始字段的名称
copyfield 'rangeof@1~2 dest@copy_range withfield@true'
注:
copyfield:代表字段数据汇聚关键字。
withfield@:true代表汇聚字段含有原始的字段名称,该关键字不声明则代表汇聚字段不含原始字段名称。
indexof@:可以使用all关键字匹配所有字段,也可以用字段的前缀,比如:cs,匹配含有cs前缀字符的字段。
dest@:代表汇聚的数据发往哪个目标字段中的关键字。
equals@:代表需要进行汇聚的明确的字段名称的关键字。