批量创建或更新文档

@param indexName 索引名
@param type      数据类型(表名)
@param list      包含id和obj的NutMap集合对象
341848
public void createOrUpdateData(String indexName, String type, List<NutMap> list) {
        BulkRequestBuilder bulkRequest = getClient().prepareBulk();
        if (list.size() > 0) {
            for (NutMap nutMap : list) {
                bulkRequest.add(getClient().prepareIndex(indexName, type).setId(nutMap.getString("id")).setSource(Lang.obj2map(nutMap.get("obj"))));
            }
            bulkRequest.execute().actionGet();
        }
    }
656616
public void remapAll(List<IndexPair> listOfOldToNew) {
    List<String> symbols = Lists.newArrayListWithCapacity(listOfOldToNew.size());
    int max = -1;
    for (int i = 0; i < listOfOldToNew.size(); i++) {
      IndexPair indexPair = listOfOldToNew.get(i);
      symbols.add(invert().keyForId(indexPair.getLeft()));
      max = Math.max(max, indexPair.getRight());
    }
    if (max >= nextId) {
      nextId = max + 1;
    }
    // now actually remap them
    for (int i = 0; i < listOfOldToNew.size(); i++) {
      IndexPair pair = listOfOldToNew.get(i);
      String symbol = symbols.get(i);
      idToSymbol.remove(pair.getLeft());
      symbolToId.remove(symbol);

      idToSymbol.put(pair.getRight(), symbol);
      symbolToId.put(symbol, pair.getRight());
    }
  }
82486
private void mapAndRememberIndexFile(File index) {
        MappedFileReader idxFileReader = null;
        try {
            idxFileReader = new MappedFileReader(index);
            mappedIndexFileReader.add(idxFileReader);
            indexFiles.add(idxFileReader.map());
        } catch(IOException e) {
            logger.error("Error mmapping " + index, e);
        }
    }
397720
protected final void append (
        ArrayList<String> list, int index, String value)
    {
        // expand the list as necessary
        while (list.size() <= index) {
            list.add("");
        }
        list.set(index, list.get(index) + value);
    }
1286789
public void setDefaultListName(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException  {
        // The request of the list is an privacy message with an empty list
        Privacy request = new Privacy();
        request.setDefaultName(listName);

        // Send the package to the server
        setRequest(request);
    }
564721
public void sendIndexToBuffer(String index, Map<String, List<String>> fields) {
		String doc = pyUtils.solrDocument(fields);
		addToBuffer(index, doc);
	}
1220206
public static <E, T extends E> void add(List<E> list, int index, T item){
        if(index<list.size())
            list.add(index, item);
        else
            list.add(item);
    }
128682
private String addIndexInputToList(String name, IndexInput in,
      String postingsFormatName) throws IOException {
    if (indexInputList.get(name) != null) {
      indexInputList.get(name).close();
    }
    if (in != null) {
      String localPostingsFormatName = postingsFormatName;
      if (localPostingsFormatName == null) {
        localPostingsFormatName = in.readString();
      } else if (!in.readString().equals(localPostingsFormatName)) {
        throw new IOException("delegate codec " + name + " doesn't equal "
            + localPostingsFormatName);
      }
      indexInputList.put(name, in);
      indexInputOffsetList.put(name, in.getFilePointer());
      return localPostingsFormatName;
    } else {
      log.debug("no " + name + " registered");
      return null;
    }
  }
1096051
def _writeIndexListElement(xmlWriter, elementName, indexList):
    
    if indexList:
        xmlIndex = xmlWriter.element('index', {'name': elementName})
        xmlIndex.__enter__()
        xmlWriter.write('\n')
        for offset, indexId in indexList:
            offsetElement = ETREE.Element('offset', {'idRef': indexId})
            offsetElement.text = str(offset)
            xmlWriter.write(offsetElement, pretty_print=True)
        xmlIndex.__exit__(None, None, None)
        xmlWriter.write('\n')
916539
public void sendBulkDataWithObjectMapperAsync(List<Object> objectBulkData,
            String index, String type) {
        executeBulkRequestAsync(buildBulkIndexRequestBuilder(objectBulkData
                .stream()
                .map(sourceObject -> jmESClient.prepareIndex(index, type)
                        .setSource(JMElasticsearchUtil
                                .buildSourceByJsonMapper(sourceObject)))
                .collect(toList())));
    }
418867
public boolean createSingleIndex(String indexName) throws
            ElasticsearchException {
        CreateIndexRequest indexRequest = new CreateIndexRequest(indexName);
        CreateIndexResponse res = this.client.admin().indices().create(indexRequest).actionGet();
        return indexExists(indexName);
    }
424157
public void updateIndex() {

        if (!isEnabled()) {
            return;
        }

        final IndexWriterConfig indexWriterConfig = new IndexWriterConfig(new StandardAnalyzer());
        indexWriterConfig
                .setCommitOnClose(true)
                .setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);

        try (IndexWriter indexWriter = new IndexWriter(directory, indexWriterConfig)) {
            final List<IPortletDefinition> portlets = portletRegistry.getAllPortletDefinitions();
            portlets.forEach(portlet -> indexPortlet(portlet, indexWriter));
        } catch (Exception e) {
            logger.error("Unable to update index", e);
        }
    }
681534
public String addDateDocuments(String indexName, String indexType, List<?> beans) throws ElasticSearchException{
		return addDocuments(this.indexNameBuilder.getIndexName(indexName),   indexType,     beans);
	}
1196019
public synchronized void refreshIndexes() {
		/*
		 * cache index by Bin name
		 */
		if (this.indexCache == null)
			this.indexCache = new TreeMap<String, Index>();

		Node[] nodes = client.getNodes();
		for (Node node : nodes) {
			if (node.isActive()) {
				try {
					String indexString = Info.request(getInfoPolicy(), node, "sindex");
					if (!indexString.isEmpty()) {
						String[] indexList = indexString.split(";");
						for (String oneIndexString : indexList) {
							Index index = new Index(oneIndexString);
							this.indexCache.put(index.toKeyString(), index);
						}
					}
					break;
				} catch (AerospikeException e) {
					log.error("Error geting Index informaton", e);
				}
			}
		}
	}
355218
public  String addDateMapDocument(String indexName, String indexType, Map params,ClientOptions clientOptions) throws ElasticSearchException{
		return addMapDocument(this.indexNameBuilder.getIndexName(indexName),   indexType,   params,clientOptions);
	}
308133
protected void buildIndexMap(RootDoc root)  {
        PackageDoc[] packages = root.specifiedPackages();
        ClassDoc[] classes = root.classes();
        if (!classesOnly) {
            if (packages.length == 0) {
                Set<PackageDoc> set = new HashSet<PackageDoc>();
                PackageDoc pd;
                for (int i = 0; i < classes.length; i++) {
                    pd = classes[i].containingPackage();
                    if (pd != null && pd.name().length() > 0) {
                        set.add(pd);
                    }
                }
                adjustIndexMap(set.toArray(packages));
            } else {
                adjustIndexMap(packages);
            }
        }
        adjustIndexMap(classes);
        if (!classesOnly) {
            for (int i = 0; i < classes.length; i++) {
                if (shouldAddToIndexMap(classes[i])) {
                    putMembersInIndexMap(classes[i]);
                }
            }
        }
        sortIndexMap();
    }
405305
private void updateEntity(String type, String id, XContentBuilder source) throws StorageException {
        try {
            String doc = source.string();
            /* JestResult response = */esClient.execute(new Index.Builder(doc)
                    .setParameter(Parameters.OP_TYPE, "index").index(getIndexName()).type(type).id(id).build()); //$NON-NLS-1$
        } catch (Exception e) {
            throw new StorageException(e);
        }
    }