2 Implementation of the 'index' subcommand.
6 from nominatim.db import status
7 from nominatim.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
35 from ..tokenizer import factory as tokenizer_factory
37 tokenizer = tokenizer_factory.get_tokenizer_for_db(args.config)
39 indexer = Indexer(args.config.get_libpq_dsn(), tokenizer,
40 args.threads or psutil.cpu_count() or 1)
42 if not args.no_boundaries:
43 indexer.index_boundaries(args.minrank, args.maxrank)
44 if not args.boundaries_only:
45 indexer.index_by_rank(args.minrank, args.maxrank)
47 if not args.no_boundaries and not args.boundaries_only \
48 and args.minrank == 0 and args.maxrank == 30:
49 with connect(args.config.get_libpq_dsn()) as conn:
50 status.set_indexed(conn, True)