2 Implementation of the 'index' subcommand.
6 from ..db import status
7 from ..db.connection import connect
9 # Do not repeat documentation of subcommand classes.
10 # pylint: disable=C0111
11 # Using non-top-level imports to avoid eventually unused imports.
12 # pylint: disable=E0012,C0415
17 Reindex all new and modified data.
22 group = parser.add_argument_group('Filter arguments')
23 group.add_argument('--boundaries-only', action='store_true',
24 help="""Index only administrative boundaries.""")
25 group.add_argument('--no-boundaries', action='store_true',
26 help="""Index everything except administrative boundaries.""")
27 group.add_argument('--minrank', '-r', type=int, metavar='RANK', default=0,
28 help='Minimum/starting rank')
29 group.add_argument('--maxrank', '-R', type=int, metavar='RANK', default=30,
30 help='Maximum/finishing rank')
34 from ..indexer.indexer import Indexer
36 indexer = Indexer(args.config.get_libpq_dsn(),
37 args.threads or psutil.cpu_count() or 1)
39 if not args.no_boundaries:
40 indexer.index_boundaries(args.minrank, args.maxrank)
41 if not args.boundaries_only:
42 indexer.index_by_rank(args.minrank, args.maxrank)
44 if not args.no_boundaries and not args.boundaries_only \
45 and args.minrank == 0 and args.maxrank == 30:
46 with connect(args.config.get_libpq_dsn()) as conn:
47 status.set_indexed(conn, True)