Complete the code to define the main component responsible for storing metadata in a search system.
class [1]: def __init__(self): self.metadata_store = {}
The MetadataStore class is responsible for storing metadata in a search system.
Complete the code to add a method that indexes a document's metadata.
def index_metadata(self, document_id, metadata): self.metadata_store[[1]] = metadata
The document_id is used as the key to store metadata in the metadata store.
Fix the error in the method that retrieves metadata for a given document.
def get_metadata(self, document_id): return self.metadata_store.get([1], None)
The method should use document_id to retrieve the metadata from the store.
Fill both blanks to create a function that filters documents by a metadata key and value.
def filter_documents(self, key, value): return [doc_id for doc_id, meta in self.metadata_store.items() if meta.get([1]) [2] value]
The function checks if the metadata's key equals the given value to filter documents.
Fill all three blanks to build a dictionary comprehension that maps document IDs to metadata values for a specific key if the value exists.
result = {doc_id: meta.get([1]) for doc_id, meta in self.metadata_store.items() if meta.get([2]) is not [3]
The comprehension maps doc_id to the metadata value for key only if the value is not None.
