Skip to content

Commit

Permalink
add status field to index for querying
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Sep 1, 2020
1 parent 5ea5748 commit 7fc297c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func MapIndexAlias(elasticURL string, alias string, newIndex string) error {
const contactQuery = `
SELECT org_id, id, modified_on, is_active, row_to_json(t) FROM (
SELECT
id, org_id, uuid, name, language, status = 'S' AS is_stopped, status = 'B' AS is_blocked, is_active, created_on, modified_on, last_seen_on,
id, org_id, uuid, name, language, status, status = 'S' AS is_stopped, status = 'B' AS is_blocked, is_active, created_on, modified_on, last_seen_on,
EXTRACT(EPOCH FROM modified_on) * 1000000 as modified_on_mu,
(
SELECT array_to_json(array_agg(row_to_json(u)))
Expand Down Expand Up @@ -591,6 +591,9 @@ const indexSettings = `
"uuid": {
"type": "keyword"
},
"status": {
"type": "keyword"
},
"language": {
"type": "keyword",
"normalizer": "lowercase"
Expand Down
3 changes: 3 additions & 0 deletions indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ func TestIndexing(t *testing.T) {
assertQuery(t, client, physicalName, elastic.NewMatchQuery("is_blocked", "true"), []int64{3})
assertQuery(t, client, physicalName, elastic.NewMatchQuery("is_stopped", "true"), []int64{2})

assertQuery(t, client, physicalName, elastic.NewMatchQuery("status", "B"), []int64{3})
assertQuery(t, client, physicalName, elastic.NewMatchQuery("status", "S"), []int64{2})

assertQuery(t, client, physicalName, elastic.NewMatchQuery("org_id", "1"), []int64{1, 2, 3, 4})

// created_on range query
Expand Down

0 comments on commit 7fc297c

Please sign in to comment.