Skip to content

Commit

Permalink
Update Postgresql to 10 on Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
dodobas committed Jan 7, 2019
1 parent 2930929 commit f57fbc3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 33 deletions.
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
language: go

addons:
postgresql: '9.6'
postgresql: '10'
apt:
packages:
- postgresql-10
- postgresql-client-10

go:
- "1.10"

before_install:
- wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.3.deb && sudo dpkg -i --force-confnew elasticsearch-6.2.3.deb
- sudo service elasticsearch start
- sudo sed -i -e '/local.*peer/s/postgres/all/' -e 's/peer\|md5/trust/g' /etc/postgresql/*/main/pg_hba.conf
- sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/10/main/postgresql.conf
- sudo service postgresql restart 10
- sleep 10

before_script:
Expand Down
56 changes: 28 additions & 28 deletions indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,34 +357,34 @@ SELECT org_id, id, modified_on, is_active, row_to_json(t) FROM (
(
SELECT jsonb_agg(f.value)
FROM (
select case
when value ? 'ward'
then jsonb_build_object(
'ward_keyword', (regexp_matches(value ->> 'ward', '(.* > )?([^>]+)'))[2]
)
else '{}' :: jsonb
end || district_value.value as value
FROM (
select case
when value ? 'district'
then jsonb_build_object(
'district_keyword', (regexp_matches(value ->> 'district', '(.* > )?([^>]+)'))[2]
)
else '{}' :: jsonb
end || state_value.value as value
FROM (
select case
when value ? 'state'
then jsonb_build_object(
'state_keyword', (regexp_matches(value ->> 'state', '(.* > )?([^>]+)'))[2]
)
else '{}' :: jsonb
end ||
jsonb_build_object('field', key) || value as value
from jsonb_each(contacts_contact.fields)
) state_value
) as district_value
select case
when value ? 'ward'
then jsonb_build_object(
'ward_keyword', trim(substring(value ->> 'ward' from '(?!.* > )([\w ]+)'))
)
else '{}' :: jsonb
end || district_value.value as value
FROM (
select case
when value ? 'district'
then jsonb_build_object(
'district_keyword', trim(substring(value ->> 'district' from '(?!.* > )([\w ]+)'))
)
else '{}' :: jsonb
end || state_value.value as value
FROM (
select case
when value ? 'state'
then jsonb_build_object(
'state_keyword', trim(substring(value ->> 'state' from '(?!.* > )([\w ]+)'))
)
else '{}' :: jsonb
end ||
jsonb_build_object('field', key) || value as value
from jsonb_each(contacts_contact.fields)
) state_value
) as district_value
) as f
) as fields,
(
Expand Down
4 changes: 2 additions & 2 deletions indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ func TestIndexing(t *testing.T) {
// phrase matches all
query = elastic.NewNestedQuery("fields", elastic.NewBoolQuery().Must(
elastic.NewMatchQuery("fields.field", "fcab2439-861c-4832-aa54-0c97f38f24ab"),
elastic.NewMatchPhraseQuery("fields.district", "King County")))
elastic.NewMatchPhraseQuery("fields.district", "King Côunty")))
assertQuery(t, client, physicalName, query, []int64{8})

query = elastic.NewNestedQuery("fields", elastic.NewBoolQuery().Must(
elastic.NewMatchQuery("fields.field", "fcab2439-861c-4832-aa54-0c97f38f24ab"),
elastic.NewMatchQuery("fields.district_keyword", "King County")))
elastic.NewMatchQuery("fields.district_keyword", "King Côunty")))
assertQuery(t, client, physicalName, query, []int64{8})

// ward query
Expand Down
4 changes: 2 additions & 2 deletions testdb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ INSERT INTO contacts_contact(id, is_active, created_by_id, created_on, modified_
(7, TRUE, -1, '2017-11-10 21:11:59.890662+00', -1, '2017-11-10 21:11:59.890662+00', 2, FALSE, 'Joanne Stone', FALSE, NULL, '7051dff0-0a27-49d7-af1f-4494239139e6', FALSE,
'{ "22d11697-edba-4186-b084-793e3b876379": { "text": "USA > Colorado", "state": "USA > Colorado"} }'),
(8, TRUE, -1, '2015-03-27 13:39:43.995812+00', -1, '2015-03-27 13:39:43.995812+00', 2, FALSE, NULL, FALSE, NULL, 'b46f6e18-95b4-4984-9926-dded047f4eb3', FALSE,
'{ "fcab2439-861c-4832-aa54-0c97f38f24ab": { "text": "USA > Washington > King County", "district": "USA > Washington > King County"} }'),
'{ "fcab2439-861c-4832-aa54-0c97f38f24ab": { "text": "USA > Washington > King Côunty", "district": "USA > Washington > King Côunty"} }'),
(9, TRUE, -1, '2017-11-10 21:11:59.890662+00', -1, '2017-11-10 21:11:59.890662+00', 2, FALSE, NULL, FALSE, NULL, '9195c8b7-6138-4d84-ac56-5192cc3d8ceb', FALSE,
'{ "a551ade4-e5a0-4d83-b185-53b515ad2f2a": { "text": "USA > Washington > King County > Central District", "ward": "USA > Washington > King County > Central District"} }'),
'{ "a551ade4-e5a0-4d83-b185-53b515ad2f2a": { "text": "USA > Washington > King Côunty > Central District", "ward": "USA > Washington > King Côunty > Central District"} }'),
(10, TRUE, -1, '2016-08-22 14:20:05.690311+00', -1, '2016-08-22 14:20:05.690311+00', 2, FALSE, NULL, FALSE, NULL, '2b8bd28d-43e0-4c34-a4bb-0f10b11fdb8a', FALSE,
'{ "fcab2439-861c-4832-aa54-0c97f38f24ab": { "text": "USA > Colorado > King", "district": "USA > Colorado > King"} }');

Expand Down

0 comments on commit f57fbc3

Please sign in to comment.