Adds a document to an index.

@param string               $indexName
@param \Elastica\Document[] $documents
@param string               $typeName

@throws \LogicException
@throws \Liip\Registry\Adaptor\AdaptorException
779613
public function registerDocuments($indexName, array $documents, $typeName = '')
    {
        $index = $this->getIndex($indexName);
        $type = $this->getOrCreateType($index, empty($typeName) ? $this->typeName : $typeName);

        try {
            $type->addDocuments($documents);
            $index->refresh();

        } catch (InvalidException $e) {
            throw new AdaptorException($e->getMessage(), $e->getCode(), $e);
        }
    }
104457
public   String getDocument(String indexName,   String documentId, Map<String, Object> options) throws ElasticSearchException{
		return getDocument(  indexName,  _doc,     documentId,   options);
	}
1155048
public function index($indexName, $type, array $data)
	{
		$index = $this->elasticSearcher->indicesManager()->getRegistered($indexName);

		$params = [
			'index' => $index->getInternalName(),
			'type'  => $type,
			'body'  => $data
		];

		// If an ID exists in the data set, use it, otherwise let elasticsearch generate one.
		if (array_key_exists('id', $data)) {
			$params['id'] = $data['id'];
		}

		return $this->elasticSearcher->getClient()->index($params);
	}
376513
public function addDocuments(array $documents, string $opType = null): self
    {
        foreach ($documents as $document) {
            $this->addDocument($document, $opType);
        }

        return $this;
    }
1330230
public function addIndex(array $columnNames, $indexName = null, array $flags = [], array $options = [])
    {
        if ($indexName === null) {
            $indexName = $this->_generateIdentifierName(
                array_merge([$this->getName()], $columnNames),
                'idx',
                $this->_getMaxIdentifierLength()
            );
        }

        return $this->_addIndex($this->_createIndex($columnNames, $indexName, false, false, $flags, $options));
    }
24006
public String addDocumentWithParentId(String indexName,   Object bean, Object parentId) throws ElasticSearchException{
		return addDocumentWithParentId( indexName,    _doc,bean,  parentId);
	}
404669
public <T> T getDocument(String indexName, String documentId, Class<T> beanType) throws ElasticSearchException{
		return getDocument(  indexName,   _doc,  documentId,  beanType);
	}
771540
public function createDocumentDatabase($documentName)
    {
        $class = $this->dm->getClassMetadata($documentName);
        if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
            throw new \InvalidArgumentException('Cannot delete document indexes for mapped super classes or embedded documents.');
        }
        $this->dm->getDocumentDatabase($documentName)->execute("function() { return true; }");
    }
290461
public function index($columnName, $indexName = '')
    {
        $indexName = ($indexName !== '') ? $indexName : $columnName;
        $this->schema = 'CREATE INDEX '.strtoupper($indexName).'_INDEX
        ON `'.$this->tableName.'` ('.$columnName.')';

        return $this;
    }
1300016
public function deleteDocumentIndexes($documentName)
    {
        $class = $this->dm->getClassMetadata($documentName);
        if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
            throw new \InvalidArgumentException('Cannot delete document indexes for mapped super classes or embedded documents.');
        }
        $this->dm->getDocumentCollection($documentName)->deleteIndexes();
    }
56050
public function getIndex($indexName)
    {
        $indexName = $this->normalizeIdentifier($indexName);
        if (! $this->hasIndex($indexName)) {
            throw SchemaException::indexDoesNotExist($indexName, $this->_name);
        }

        return $this->_indexes[$indexName];
    }
537783
public function deleteDocuments($indexName, $indexType, array $ids)
    {
        $index = $this->getIndex($indexName);
        $type = $index->getType($indexType);

        return $this->getClient()->deleteIds($ids, $index, $type);
    }
1079941
public String addDateDocumentsWithIdKey(String indexName, String indexType, List<Map> beans,String docIdKey) throws ElasticSearchException{
		return addDocumentsWithIdKey(this.indexNameBuilder.getIndexName(indexName),   indexType,     beans,docIdKey);
	}
484848
public String addMapDocument(String indexName, String indexType, Map params,ClientOptions clientOptions) throws ElasticSearchException{
		Object docId = null;
		Object parentId = null;
		Object routing = null;
		String refreshOption = null;
		if(clientOptions != null) {
			refreshOption = clientOptions.getRefreshOption();
			docId = clientOptions.getIdField() != null ? params.get(clientOptions.getIdField()) : null;
			parentId = clientOptions.getParentIdField() != null ? params.get( clientOptions.getParentIdField()) : null;
			routing = clientOptions.getRountField() != null ? params.get(clientOptions.getRountField()) : null;
		}
		return addDocument(  indexName,   indexType,   params,  docId,  parentId,  routing,  refreshOption);
	}
445649
public void indexDocument(String indexName, String mappingName, String id, XContentBuilder document)
            throws Exception {
        client.prepareIndex(indexName, mappingName, id).setSource(document).get();
    }
1124977
public   String getDocument(String indexName,  String documentId) throws ElasticSearchException{
		return getDocument(  indexName,  _doc,  documentId);
	}
412494
public function add_document($document, $fileindexing = false) {
        global $DB;

        $doc = (object)$document->export_for_engine();

        // Moodle's ids using DML are always autoincremented.
        $doc->docid = $doc->id;
        unset($doc->id);

        $id = $DB->get_field('search_simpledb_index', 'id', array('docid' => $doc->docid));
        try {
            if ($id) {
                $doc->id = $id;
                $DB->update_record('search_simpledb_index', $doc);
            } else {
                $DB->insert_record('search_simpledb_index', $doc);
            }

        } catch (\dml_exception $ex) {
            debugging('dml error while trying to insert document with id ' . $doc->docid . ': ' . $ex->getMessage(),
                DEBUG_DEVELOPER);
            return false;
        }

        return true;
    }