Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion importers/src/main/groovy/whelk/importer/ImporterMain.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ class ImporterMain {

@Command(args='[COLLECTION] [-t NUMBEROFTHREADS]')
void reindex(String... args) {
def cli = new CliBuilder(usage: 'reindex [collection] -[ht]')
def cli = new CliBuilder(
usage: 'reindex [collection] -[ht]',
header: '\n[collection] = auth|bib|hold|none|@type:<type>\n'
)
// Create the list of options.
cli.with {
h longOpt: 'help', 'Show usage information'
Expand Down
14 changes: 12 additions & 2 deletions importers/src/main/groovy/whelk/reindexer/ElasticReindexer.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package whelk.reindexer

import groovy.util.logging.Log4j2 as Log
import whelk.Document
import whelk.JsonLd
import whelk.Whelk
import whelk.util.BlockingThreadPool
import whelk.util.Unicode

@Log
class ElasticReindexer {
Expand Down Expand Up @@ -73,9 +75,17 @@ class ElasticReindexer {
log.info("Collection(s) to be indexed: ${collections}")
threadPool = BlockingThreadPool.simplePool(numberOfThreads)
collections.each { collection ->
log.info("Indexing collection ${collection}")
List<Document> documents = []
for (document in whelk.storage.loadAll(collection)) {
Iterable<Document> iterable;
if (collection.startsWith(JsonLd.TYPE_KEY+":")) {
var type = Unicode.stripPrefix(collection, JsonLd.TYPE_KEY+":")
iterable = whelk.loadAllByType(type)
log.info("Indexing type ${type}")
} else {
iterable = whelk.storage.loadAll(collection)
log.info("Indexing collection ${collection}")
}
for (document in iterable) {
if ( ! document.getDeleted() ) {
documents.add(document)
counter++
Expand Down
Loading