Adding a Handler

Expanding the coverage of the facet scanner involves adding the dataset to the collection map and creating a new handler class.

  1. Collection Map (facet_scanner/collection_handlers/utils/collection_map.py

  2. Handler Class (facet_scanner/collection_handlers/.)

All handler classes should inherit from :doc:`api/collection_handlers`

This base class provides abstract methods and properties which must be implemented in order to successfully implement a new handler.

Check the MRO to make sure that all the required methods are present. You are free to create additional methods to aide in generating the facet content.

Collection Map

A Python dictionary which contains the mapping from path to collection handler.py

The key pairs are formed:

'/path/to/dataset: dict(handler='facet_scanner.collection_handlers.<handler_module>.<handler_class>')

The <module>.<handler_class> variables are substituted to match the new collection handler.

Handler Class

The handler class does all the work of extracting the facets from the specified files in the COLLECTION_MAP

All handler classes should inherit from the Collection Handlers

MRO

When the facet_scanner is run, the methods are called in the following order:

Facet Scanner CMD MRO

  1. facet_scanner.scripts.facet_scanner_cmd.FacetExtractor.process_path

  2. facet_scanner.core.facet_scanner.FacetScanner.get_handler

  3. facet_scanner.collection_handlers.utils.facet_factory.FacetFactory.get_handler

  4. facet_scanner.collection_handlers.base.CollectionHandler.export_facets

  5. facets_scanner.core.elasticsearch_connection.ElasticsearchConnection.get_query

  6. facets_scanner.core.elasticsearch_connection.ElasticsearchConnection.get_hits

  7. facet_scanner.collection_handlers.base.CollectionHandler.lotus_submit

Lotus Facet Scanner MRO

  1. facet_scanner.scripts.lotus_facet_scanner.LotusFacetScanner.process_path

  2. facet_scanner.core.facet_scanner.FacetScanner.get_handler

  3. facet_scanner.collection_handlers.utils.facet_factory.FacetFactory.get_handler

  4. facet_scanner.collection_handlers.base.CollectionHandler.update_facets

  5. facet_scanner.collection_handlers.base.CollectionHandler._facet_generator

  6. facet_scanner.collection_handlers.base.CollectionHandler.get_facets