创建或者更新索引文档
@param indexName
@param indexType
@param params
@return
@throws ElasticSearchException
355218
public  String addDateMapDocument(String indexName, String indexType, Map params,ClientOptions clientOptions) throws ElasticSearchException{
		return addMapDocument(this.indexNameBuilder.getIndexName(indexName),   indexType,   params,clientOptions);
	}
664917
public String addMapDocument(String indexName,  Map bean, ClientOptions clientOptions) throws ElasticSearchException{
		return addDateMapDocument(  indexName,  _doc,   bean,clientOptions);
	}
740124
private static void updateIndexWithSettingsInElasticsearch(RestClient client, String index, String settings) throws Exception {
		logger.trace("updateIndex([{}])", index);

		assert client != null;
		assert index != null;


		if (settings != null) {
			logger.trace("Found update settings for index [{}]: [{}]", index, settings);
			logger.debug("updating settings for index [{}]", index);
            Request request = new Request("PUT", "/" + index + "/_settings");
            request.setJsonEntity(settings);
			client.performRequest(request);
		}

		logger.trace("/updateIndex([{}])", index);
	}
74173
def reindex(self, new_index_name: str, identifier_key: str, **kwargs) -> 'ElasticIndex':
        
        if 'url' not in kwargs:
            kwargs['url'] = self.url
        if 'doc_type' not in kwargs:
            kwargs['doc_type'] = self.doc_type
        if 'mapping' not in kwargs:
            kwargs['mapping'] = self.mapping
        new_index = ElasticIndex(new_index_name, **kwargs)

        for results in self.scroll(size=500):
            new_index.bulk(results, identifier_key)
        return new_index
964157
@When("^I index a document in the index named '(.+?)' using the mapping named '(.+?)' with key '(.+?)' and value '(.+?)'$")
    public void indexElasticsearchDocument(String indexName, String mappingName, String key, String value) throws Exception {
        ArrayList<XContentBuilder> mappingsource = new ArrayList<XContentBuilder>();
        XContentBuilder builder = jsonBuilder().startObject().field(key, value).endObject();
        mappingsource.add(builder);
        commonspec.getElasticSearchClient().createMapping(indexName, mappingName, mappingsource);
    }
1124977
public   String getDocument(String indexName,  String documentId) throws ElasticSearchException{
		return getDocument(  indexName,  _doc,  documentId);
	}
638057
public String addDateMapDocument(String indexName, String indexType, Map bean) throws ElasticSearchException{
		return addDocument(  this.indexNameBuilder.getIndexName(indexName),   indexType,   bean,null,null,null,(String )null);
	}
1244415
private void refreshIndexes(int version) {
        try {
            Collection<Path> paths = new ArrayList<>();
            MemoryFileManager fm = proc.taskFactory.fileManager();

            appendPaths(fm, StandardLocation.PLATFORM_CLASS_PATH, paths);
            appendPaths(fm, StandardLocation.CLASS_PATH, paths);
            appendPaths(fm, StandardLocation.SOURCE_PATH, paths);

            Map<Path, ClassIndex> newIndexes = new HashMap<>();

            //setup existing/last known data:
            for (Path p : paths) {
                ClassIndex index = PATH_TO_INDEX.get(p);
                if (index != null) {
                    newIndexes.put(p, index);
                }
            }

            synchronized (currentIndexes) {
                //temporary setting old data:
                currentIndexes.clear();
                currentIndexes.putAll(newIndexes);
            }

            //update/compute the indexes if needed:
            for (Path p : paths) {
                waitIndexingNotSuspended();

                ClassIndex index = indexForPath(p);
                newIndexes.put(p, index);
            }

            synchronized (currentIndexes) {
                currentIndexes.clear();
                currentIndexes.putAll(newIndexes);
            }
        } catch (Exception ex) {
            proc.debug(ex, "SourceCodeAnalysisImpl.refreshIndexes(" + version + ")");
        } finally {
            synchronized (currentIndexes) {
                indexVersion = version;
            }
        }
    }
396151
public function addDocuments($documents, $indexName = '', $indexType = '')
    {
        if ("" === $indexName && isset($documents[0])) {
            $indexName = $documents[0]->getIndexName();
        } else {
            $indexName = $this->indexNamePrefix . $indexName;
        }

        $this->mapProviders(function (SearchProviderInterface $provider) use ($documents, $indexName, $indexType) {

            $documents = array_map(function (DocumentReference $document) use ($provider) {
                return $provider->createDocument(
                    $document->getDocument(),
                    $document->getUid(),
                    $document->getIndexName(),
                    $document->getIndexType()
                );
            }, $documents);

            $provider->addDocuments($documents, $indexName, $indexType);
        });
    }
641823
public void index(String indexName, String indexType, Map<CharSequence, CharSequence> idJsonMap) {
        index(
                idJsonMap.entrySet().stream()
                        .map(entry -> new IndexRequest.IndexRequestBuilder(indexName, indexType, entry.getValue().toString())
                                .withId(entry.getKey().toString()).build()
                        )
                        .collect(toList())
        );
    }
1331780
public String addDateDocumentsWithIdOptions(String indexName, String indexType, List<Object> beans,String docIdField,String refreshOption) throws ElasticSearchException{
		return addDocumentsWithIdField(this.indexNameBuilder.getIndexName(indexName),   indexType,     beans,docIdField,refreshOption);
	}
240196
public static final IndexReference indexRef(String indexName, IndexType type) {
        if (type == null) {
            return new IndexReference("`" + indexName + "`");
        }
        return new IndexReference("`" + indexName + "` USING " + type.toString());
    }
566629
public String addMapDocument(String indexName , Map bean) throws ElasticSearchException{
		return addMapDocument(  indexName,  _doc,   bean);
	}
783183
@SuppressWarnings("nls")
    private void indexEntity(String type, String id, XContentBuilder sourceEntity, boolean refresh)
            throws StorageException {
        try {
            String json = sourceEntity.string();
            JestResult response = esClient.execute(new Index.Builder(json).refresh(refresh).index(getIndexName())
                    .setParameter(Parameters.OP_TYPE, "create").type(type).id(id).build());
            if (!response.isSucceeded()) {
                throw new StorageException("Failed to index document " + id + " of type " + type + ": " + response.getErrorMessage());
            }
        } catch (StorageException e) {
            throw e;
        } catch (Exception e) {
            throw new StorageException(e);
        }
    }
24006
public String addDocumentWithParentId(String indexName,   Object bean, Object parentId) throws ElasticSearchException{
		return addDocumentWithParentId( indexName,    _doc,bean,  parentId);
	}
1085886
private static void createTypeWithMappingInElasticsearch(RestHighLevelClient client, String index, String mapping)
            throws Exception {
        logger.trace("createTypeWithMappingInElasticsearch([{}])", index);

        assert client != null;
        assert index != null;

        if (mapping != null) {
            // Create mapping
            client.indices().putMapping(new PutMappingRequest(index).source(mapping, XContentType.JSON), RequestOptions.DEFAULT);
        } else {
            logger.trace("no content given for mapping. Ignoring mapping creation in index [{}].", index);
        }

        logger.trace("/createTypeWithMappingInElasticsearch([{}])", index);
    }
369904
private void addToIndex(Map<String, String> param) throws Exception {
        String doc = writeUpdateString(param);
        addToBuffer(doc);
    }