def _create_index(self, index_name: str) -> None:
    if self.options['index_properties']:
        create_request_url = f"{self.options['es_url'].rstrip('/')}/{index_name}/"
        self.logger.debug(('Calling Elasticsearch API to create an index with specified properties, ' + f'URL: {create_request_url}'))
        create_response = self._http_request(create_request_url, 'PUT', {'Content-Type': 'application/json; charset=utf-8'}, json.dumps(self.options['index_properties'], ensure_ascii=False).encode('utf-8'))
        create_response_data = json.loads(create_response['data'].decode('utf-8'))
        self.logger.debug(f"Response received, status: {create_response['status']}")
        self.logger.debug(f"Response headers: {create_response['headers']}")
        self.logger.debug(f'Response data: {create_response_data}')
        if ((create_response['status'] == 200) and (create_response_data.get('acknowledged', None) is True)):
            self.logger.debug('Index created')
        elif ((create_response['status'] == 400) and (create_response_data.get('error', {}).get('type', '') == 'resource_already_exists_exception')):
            self.logger.debug('Index already exists')
        else:
            error_message = 'Failed to create an index'
            self.logger.error(f'{error_message}')
            raise RuntimeError(f'{error_message}')
    else:
        self.logger.debug('An index without specific properties will be created')
    if self.options['use_chapters']:
        self.logger.debug('Only files mentioned in chapters will be indexed')
        markdown_files_paths = self._get_chapters_paths()
    else:
        self.logger.debug('All files of the project will be indexed')
        markdown_files_paths = self.working_dir.rglob('*.md')
    data_for_indexing = ''
    for markdown_file_path in markdown_files_paths:
        self.logger.debug(f'Processing the file: {markdown_file_path}')
        with open(markdown_file_path, encoding='utf8') as markdown_file:
            markdown_content = markdown_file.read()
        if markdown_content:
            url = self._get_url(markdown_file_path)
            title = self._get_title(markdown_content)
            if ((self.options['format'] == 'html') or (self.options['format'] == 'plaintext')):
                self.logger.debug(f"Converting source Markdown content to: {self.options['format']}")
                content = markdown(markdown_content)
                if (self.options['format'] == 'plaintext'):
                    soup = BeautifulSoup(content, 'lxml')
                    for non_text_node in soup(['style', 'script']):
                        non_text_node.extract()
                    content = soup.get_text()
                    if self.options['escape_html']:
                        self.logger.debug('Escaping HTML syntax')
                        if title:
                            title = self._escape_html(title)
                        content = self._escape_html(content)
            else:
                self.logger.debug('Leaving source Markdown content unchanged')
                content = markdown_content
            self.logger.debug(f'Adding the page, URL: {url}, title: {title}')
            data_for_indexing += (('{"index": {}}\n' + json.dumps({'url': url, 'title': title, 'content': content}, ensure_ascii=False)) + '\n')
        else:
            self.logger.debug('It seems that the file has no content')
    self.logger.debug(f'Data for indexing: {data_for_indexing}')
    update_request_url = f"{self.options['es_url'].rstrip('/')}/{index_name}/_bulk?refresh"
    self.logger.debug(f'Calling Elasticsearch API to add the content to the index, URL: {update_request_url}')
    update_response = self._http_request(update_request_url, 'POST', {'Content-Type': 'application/json; charset=utf-8'}, data_for_indexing.encode('utf-8'))
    update_response_data = json.loads(update_response['data'].decode('utf-8'))
    self.logger.debug(f"Response received, status: {update_response['status']}")
    self.logger.debug(f"Response headers: {update_response['headers']}")
    self.logger.debug(f'Response data: {update_response_data}')
    if ((update_response['status'] != 200) or update_response_data.get('errors', True)):
        error_message = 'Failed to add content to the index'
        self.logger.error(f'{error_message}')
        raise RuntimeError(f'{error_message}')
    return None
def _create_index(self, index_name: str) -> None:
    if self.options['index_properties']:
        create_request_url = f"{self.options['es_url'].rstrip('/')}/{index_name}/"
        self.logger.debug(('Calling Elasticsearch API to create an index with specified properties, ' + f'URL: {create_request_url}'))
        create_response = self._http_request(create_request_url, 'PUT', {'Content-Type': 'application/json; charset=utf-8'}, json.dumps(self.options['index_properties'], ensure_ascii=False).encode('utf-8'))
        create_response_data = json.loads(create_response['data'].decode('utf-8'))
        self.logger.debug(f"Response received, status: {create_response['status']}")
        self.logger.debug(f"Response headers: {create_response['headers']}")
        self.logger.debug(f'Response data: {create_response_data}')
        if ((create_response['status'] == 200) and (create_response_data.get('acknowledged', None) is True)):
            self.logger.debug('Index created')
        elif ((create_response['status'] == 400) and (create_response_data.get('error', {}).get('type', ) == 'resource_already_exists_exception')):
            self.logger.debug('Index already exists')
        else:
            error_message = 'Failed to create an index'
            self.logger.error(f'{error_message}')
            raise RuntimeError(f'{error_message}')
    else:
        self.logger.debug('An index without specific properties will be created')
    if self.options['use_chapters']:
        self.logger.debug('Only files mentioned in chapters will be indexed')
        markdown_files_paths = self._get_chapters_paths()
    else:
        self.logger.debug('All files of the project will be indexed')
        markdown_files_paths = self.working_dir.rglob('*.md')
    data_for_indexing = 
    for markdown_file_path in markdown_files_paths:
        self.logger.debug(f'Processing the file: {markdown_file_path}')
        with open(markdown_file_path, encoding='utf8') as markdown_file:
            markdown_content = markdown_file.read()
        if markdown_content:
            url = self._get_url(markdown_file_path)
            title = self._get_title(markdown_content)
            if ((self.options['format'] == 'html') or (self.options['format'] == 'plaintext')):
                self.logger.debug(f"Converting source Markdown content to: {self.options['format']}")
                content = markdown(markdown_content)
                if (self.options['format'] == 'plaintext'):
                    soup = BeautifulSoup(content, 'lxml')
                    for non_text_node in soup(['style', 'script']):
                        non_text_node.extract()
                    content = soup.get_text()
                    if self.options['escape_html']:
                        self.logger.debug('Escaping HTML syntax')
                        if title:
                            title = self._escape_html(title)
                        content = self._escape_html(content)
            else:
                self.logger.debug('Leaving source Markdown content unchanged')
                content = markdown_content
            self.logger.debug(f'Adding the page, URL: {url}, title: {title}')
            data_for_indexing += (('{"index": {}}\n' + json.dumps({'url': url, 'title': title, 'content': content}, ensure_ascii=False)) + '\n')
        else:
            self.logger.debug('It seems that the file has no content')
    self.logger.debug(f'Data for indexing: {data_for_indexing}')
    update_request_url = f"{self.options['es_url'].rstrip('/')}/{index_name}/_bulk?refresh"
    self.logger.debug(f'Calling Elasticsearch API to add the content to the index, URL: {update_request_url}')
    update_response = self._http_request(update_request_url, 'POST', {'Content-Type': 'application/json; charset=utf-8'}, data_for_indexing.encode('utf-8'))
    update_response_data = json.loads(update_response['data'].decode('utf-8'))
    self.logger.debug(f"Response received, status: {update_response['status']}")
    self.logger.debug(f"Response headers: {update_response['headers']}")
    self.logger.debug(f'Response data: {update_response_data}')
    if ((update_response['status'] != 200) or update_response_data.get('errors', True)):
        error_message = 'Failed to add content to the index'
        self.logger.error(f'{error_message}')
        raise RuntimeError(f'{error_message}')
    return None