Skip to content

Instantly share code, notes, and snippets.

View quoeamaster's full-sized avatar

Takara-Mono, Jason quoeamaster

View GitHub Profile
PUT courses-02
{
"settings": {
"analysis": {
"char_filter": {
"email_dot_replacer": {
"type": "mapping",
"mappings": [
". => -"
]
PUT courses-01/_doc/A123?pipeline=test_p2
{
"instructors": "donna.karen@uni.gov,jojo.star.crusade@uni.gov",
"course": {
"name": "Introduction to Economics",
"medium": "zoom"
}
}
/* search */
GET courses-01/_search
PUT _ingest/pipeline/test_p2
{
"processors": [
{
"gsub": {
"field": "instructors",
"pattern": "\\.",
"replacement": "-"
}
}
POST _analyze
{
"analyzer": "standard",
"text": ["jojo.star.crusade@uni.gov"]
}
...
/* results */
{
PUT courses-00/_doc/A123
{
"instructors": "donna.karen@uni.gov,jojo.star.crusade@uni.gov",
"course": {
"name": "Introduction to Economics",
"medium": "zoom"
}
}
/* somehow no results return by supplying a partial email address like "jojo" */
GET courses-00/_search
@quoeamaster
quoeamaster / clickhouse_sum_02.sql
Created January 6, 2022 07:53
clickhouse_sum_02.sql
# add another column... to test the confusing
ALTER TABLE test_summing_tree
ADD COLUMN `country` String;
# empty the table
ALTER TABLE test_summing_tree
DELETE WHERE 1 = 1;
# add records again with some confusions of the country value
@quoeamaster
quoeamaster / clickhouse_sum_01.sql
Created January 6, 2022 07:47
clickhouse_sum_01.sql
CREATE TABLE test_summing_tree
(
`brand` String,
`sold_at` DateTime,
`qty` UInt32,
`price` Float
)
ENGINE = SummingMergeTree((qty, price))
PARTITION BY toYYYYMM(sold_at)
ORDER BY (sold_at, brand);
@quoeamaster
quoeamaster / clickhouse_mv3.sql
Last active December 22, 2021 08:09
clickhouse_mv3.sql
CREATE MATERIALIZED VIEW mv_transactions_2 TO transactions4report2 AS
SELECT
customerID,
p.name as paymentName,
qty,
price,
ts
FROM transactions AS t, paymentMethod AS p
WHERE t.paymentMethod = p.id;
@quoeamaster
quoeamaster / clickhouse_mv2.sql
Last active December 22, 2021 07:57
clickhouse_mv2.sql
# create the helper tables
CREATE TABLE IF NOT EXISTS paymentMethod
(
`id` Int,
`name` String
)
ENGINE = MergeTree
ORDER BY id;
insert into paymentMethod values (0, 'cash');
@quoeamaster
quoeamaster / clickhouse_mv1.sql
Created December 22, 2021 05:15
clickhouse_mv1.sql
# create a target table
CREATE TABLE IF NOT EXISTS transactions4report
(
`customerID` String,
`paymentMethod` Int,
`qty` Int,
`price` Float,
`ts` dateTime
)
ENGINE = MergeTree