geotribu_cli.search.search_content module#

geotribu_cli.search.search_content.filter_content_listing(json_filepath)#

Filtering out irrelevant docs from content listing to reduce number of documents to index.

Paramètres:

json_filepath (Path) – path to the input JSON file

Renvoie:

filtered object

Type renvoyé:

filter

geotribu_cli.search.search_content.format_output_result(result, search_term=None, format_type=None, count=5, search_filter_dates=None, search_filter_type=None)#

Format result according to output option.

Paramètres:
  • result (list[dict]) – result to format

  • search_term (str, optional) – term used for search. Defaults to None.

  • format_type (str, optional) – format output option. Defaults to None.

  • count (int, optional) – default number of results to display. Defaults to 5.

  • search_filter_dates (tuple) – dates used to filter search. Defaults to None.

  • search_filter_type (str) – type used to filter search. Defaults to None.

Renvoie:

formatted result ready to print

Type renvoyé:

str

geotribu_cli.search.search_content.generate_index_from_docs(input_documents_to_index, index_ref_id, index_configuration, index_fieds_definition)#

Build search index from input documents.

Paramètres:
  • input_documents_to_index (dict) – documents to index

  • index_ref_id (str) – field to use as index primary key

  • index_configuration (dict) – index configuration (language, etc.)

  • index_fieds_definition (List[dict]) – fields settings (boost, etc.)

Renvoie:

lunr Index

Type renvoyé:

Index

geotribu_cli.search.search_content.parser_search_content(subparser)#

Set the argument parser for search-content subcommand.

Paramètres:

subparser (argparse.ArgumentParser) – parser to set up

Renvoie:

parser ready to use

Type renvoyé:

argparse.ArgumentParser

geotribu_cli.search.search_content.run(args)#

Run the sub command logic.

There are 2 files involved (names can vary):

  • site_content_listing.json: the downloaded file from the website which is just a listing of contents

  • site_search_index.json (= args.local_index_file): the file with the indexed contents with lunr built locally from the listing file.

Process:

  1. Check if the local index file exists and is up to date

  2. If not:
    1. Download the website contents listing from remote

    2. Generate a local index from the contents listing

  3. Load the local index

  4. Perform the search

Paramètres:

args (argparse.Namespace) – arguments passed to the subcommand