Examples of IndexRequestBuilder


Examples of org.elasticsearch.client.action.index.IndexRequestBuilder

   
   
   
    // Set up the es index response
    String uuid = UUID.randomUUID().toString();
    IndexRequestBuilder response = client.prepareIndex("nutch", "index", uuid);
    Map<String,Object> mp = new HashMap<String, Object>();
           
      for(final Entry<String, NutchField> e : doc) { 
        for (final Object val : e.getValue().getValues()) {
        String key;
          // normalise the string representation for a Date
          Object val2 = val;
          if (val instanceof Date){
            key = e.getKey();
            val2 = DateUtil.getThreadLocalDateFormat().format(val);
            mp.put(key, val2);
          } else {
            key = e.getKey();
            mp.put(key, val);
          }
         
        }
      }
      // insert the document into elasticsearch
      response.setSource(mp);
      response.execute();
     
  }
View Full Code Here

Examples of org.elasticsearch.client.action.index.IndexRequestBuilder

     * Index the file as a child doc
     */
    public void indexChild(String id, Map<String, Object> objectMap) throws IOException {
        XContentBuilder builder = XContentFactory.jsonBuilder();

        IndexRequestBuilder indexRequestbuilder = client.prepareIndex(INDEX_NAME, CHILD_TYPE_NAME, id);
        indexRequestbuilder = indexRequestbuilder.setParent(id);
        indexRequestbuilder = indexRequestbuilder.setSource(builder.map(objectMap));
        indexRequestbuilder.execute().actionGet();
    }
View Full Code Here

Examples of org.elasticsearch.client.action.index.IndexRequestBuilder

* @author kimchy (shay.banon)
*/
public abstract class AbstractClient implements InternalClient {

    @Override public IndexRequestBuilder prepareIndex() {
        return new IndexRequestBuilder(this, null);
    }
View Full Code Here

Examples of org.elasticsearch.client.action.index.IndexRequestBuilder

        return response.getCount();
    }

    public void feedDoc(String twitterId, XContentBuilder b) {
//        String getIndexName() = new SimpleDateFormat("yyyyMMdd").format(tw.getCreatedAt());
        IndexRequestBuilder irb = client.prepareIndex(getIndexName(), getIndexType(), twitterId).
                setConsistencyLevel(WriteConsistencyLevel.DEFAULT).
                setSource(b);
        irb.execute().actionGet();
    }
View Full Code Here

Examples of org.elasticsearch.client.action.index.IndexRequestBuilder

  public boolean addDocument(JsonElement docJson, String _id, boolean bAllowOverwrite, String sParentId) {
   
    if (null != _multiIndex) {
      throw new RuntimeException("addDocument not supported on multi-index manager");
    }
    IndexRequestBuilder irb = _elasticClient.prepareIndex(_sIndexName, _sIndexType).setSource(docJson.toString());
    if (null != _id) {
      irb.setId(_id);
    }//TESTED
    else { // If an _id is already specified use that
      JsonElement _idJson = docJson.getAsJsonObject().get("_id");
      if (null != _idJson) {
        _id = _idJson.getAsString();
        if (null != _id) {
          irb.setId(_id);
        }       
      }
    }//TOTEST
   
    if (!bAllowOverwrite) {
      irb.setOpType(OpType.CREATE);
    }//TESTED
   
    if (null != sParentId) {
      irb.setParent(sParentId);
    }
   
    // This ensures that the write goes through if I can write to any nodes, which seems sensible
    // You could always check the response and handle minimal success like failure if you want
    irb.setConsistencyLevel(WriteConsistencyLevel.ONE);
 
    try {
      irb.execute().actionGet();
    }
    catch (org.elasticsearch.transport.RemoteTransportException e) {     
      boolean bDocAlreadyExists =
        e.contains(org.elasticsearch.index.engine.DocumentAlreadyExistsEngineException.class) // 0.18
          ||
View Full Code Here

Examples of org.elasticsearch.client.action.index.IndexRequestBuilder

    return new GetRequestBuilder(_superClient.prepareGet(arg0, arg1, arg2));
  }

  //@Override
  public org.elasticsearch.client.action.index.IndexRequestBuilder prepareIndex() {
    return new IndexRequestBuilder(_superClient.prepareIndex());
  }
View Full Code Here

Examples of org.elasticsearch.client.action.index.IndexRequestBuilder

    return new IndexRequestBuilder(_superClient.prepareIndex());
  }

  //@Override
  public org.elasticsearch.client.action.index.IndexRequestBuilder prepareIndex(String arg0, String arg1) {
    return new IndexRequestBuilder(_superClient.prepareIndex(arg0, arg1));
  }
View Full Code Here

Examples of org.elasticsearch.client.action.index.IndexRequestBuilder

  }

  //@Override
  public org.elasticsearch.client.action.index.IndexRequestBuilder prepareIndex(String arg0, String arg1,
      String arg2) {
    return new IndexRequestBuilder(_superClient.prepareIndex(arg0, arg1, arg2));
  }
View Full Code Here

Examples of org.elasticsearch.client.action.index.IndexRequestBuilder

    return new GetRequestBuilder(_superClient.prepareGet(arg0, arg1, arg2));
  }

  //@Override
  public org.elasticsearch.client.action.index.IndexRequestBuilder prepareIndex() {
    return new IndexRequestBuilder(_superClient.prepareIndex());
  }
View Full Code Here

Examples of org.elasticsearch.client.action.index.IndexRequestBuilder

    return new IndexRequestBuilder(_superClient.prepareIndex());
  }

  //@Override
  public org.elasticsearch.client.action.index.IndexRequestBuilder prepareIndex(String arg0, String arg1) {
    return new IndexRequestBuilder(_superClient.prepareIndex(arg0, arg1));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.