Skip to content

Commit

Permalink
fix(ingestion): create contig indices once after final header line found
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Oct 31, 2024
1 parent ff08986 commit 87642d2
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/api/services/ingestion.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,27 +408,27 @@ func (i *IngestionService) ProcessVcf(
}
}

discoveredHeaders = true
// If we got to the VCF final header line, we've found all the contigs possible
// --> create required indices with mappings to ensure ES types are consistent
fmt.Printf("Got %d contigs: %v\n", len(contigs), contigs)
for _, c := range contigs {
var client = i.ElasticsearchClient

mappings, _ := json.Marshal(indexes.VARIANT_INDEX_MAPPING)
var createBody = fmt.Sprintf(`{"mappings": %s}`, mappings)

client.Indices.Create(
variantIndexName(c),
client.Indices.Create.WithBody(strings.NewReader(createBody)),
)
}

fmt.Println("Found the headers: ", headers)
continue
discoveredHeaders = true
}
continue
}

// Create required indices with mappings to ensure ES types are cosnsitent
for _, c := range contigs {
var client = i.ElasticsearchClient

mappings, _ := json.Marshal(indexes.VARIANT_INDEX_MAPPING)
var createBody = fmt.Sprintf(`{"mappings": %s}`, mappings)

client.Indices.Create(
variantIndexName(c),
client.Indices.Create.WithBody(strings.NewReader(createBody)),
)
}

// take a spot in the queue
lineProcessingQueue <- true
_fileWG.Add(1)
Expand Down

0 comments on commit 87642d2

Please sign in to comment.