Package com.ikanow.infinit.e.data_model.index.document

Examples of com.ikanow.infinit.e.data_model.index.document.DocumentPojoIndexMap$DocumentPojoSerializer


  private void sendToIndex(ElasticSearchManager indexManager, LinkedList<DocumentPojo> docsToAdd) {
    try {
      if (!docsToAdd.isEmpty()) {
        if (!_diagnosticMode) {
          indexManager.bulkAddDocuments(IndexManager.mapListToIndex(docsToAdd, new TypeToken<LinkedList<DocumentPojo>>(){},
              new DocumentPojoIndexMap()), DocumentPojo._id_, null, true);
        }
        else {
          System.out.println("StoreAndIndexManager.addToSearch: index " + docsToAdd.size() + " documents to " + indexManager.getIndexName());
        }             
        docsToAdd.clear();       
View Full Code Here


   
// Index testing:
   
    ////////////////////////////////////////////////
    //CANONICAL EXAMPLE:
    DocumentPojoIndexMap docMap = new DocumentPojoIndexMap();
    System.out.println("DOC_INDEX=" + IndexManager.mapToIndex(doc, docMap));
   
    ////////////////////////////////////////////////
    // Check use of enums in Entity pojo works
    EntityPojo testEnt = new EntityPojo();
    testEnt.setDimension(EntityPojo.Dimension.Where);
    System.out.println("ENT1=" + new GsonBuilder().setPrettyPrinting().create().toJson(testEnt));   
    System.out.println("DIM=" + testEnt.getDimension());
    BasicDBObject testEntDb = new BasicDBObject("dimension", "Who");
    testEnt = new Gson().fromJson(testEntDb.toString(), EntityPojo.class);
    System.out.println("ENT2=" + new GsonBuilder().setPrettyPrinting().create().toJson(testEnt));
    try {
      testEntDb = new BasicDBObject("dimension", "what");
      testEnt = BaseDbPojo.getDefaultBuilder().create().fromJson(testEntDb.toString(), EntityPojo.class);
      System.out.println("***FAIL=" + BaseDbPojo.getDefaultBuilder().setPrettyPrinting().create().toJson(testEnt));
    }
    catch (Exception e) {
      System.out.println("ENT3: Correctly failed with illegal dimension type");
    }
   
    ////////////////////////////////////////////////
    // Metadata transformations based on type:
   
    String metadataObjStr = "{ 'test__long': 3, 'test_long': '3', 'error__long': { 'field1': 'no'}, "+
      "'test_arrayObj': [ { 'field1': 'test' } ], 'test_nestedArrayObj': [ [ { 'field1': 'test' } ]  ], "+
      "'test_array': [ 'val' ], 'test_nestedArray': [ [ 'val' ] ], "+
      "'test_obj': { 'field1': 'string' }, 'test_nestedObj': { 'field1': 'string', 'field2': { 'field3': 'string' }},"+
      "'test_null1': {}, test_null2: null"+
      "}";
   
    BasicDBObject metadataObj = (BasicDBObject) com.mongodb.util.JSON.parse(metadataObjStr);
   
    doc.addToMetadata("TestMeta", metadataObj);
    System.out.println("DOC_META=" + docMap.extendBuilder(BaseApiPojo.getDefaultBuilder()).setPrettyPrinting().create().toJson(doc));
   
// Changes to new ElasticSearch construct (particularly for bulk add)
   
    ElasticSearchManager indexManager = IndexManager.createIndex("test", null, false, null, null, ImmutableSettings.settingsBuilder());
   
    BulkResponse result = null;
    // All docs
    result = indexManager.bulkAddDocuments(IndexManager.mapListToIndex(docset, new TypeToken<Set<DocumentPojo>>(){},
                                  new DocumentPojoIndexMap()), "_id", null, true);
    if (result.hasFailures()) {
      System.out.print("****** FAILED: ");
      System.out.println(result.buildFailureMessage());
    }
   
View Full Code Here

TOP

Related Classes of com.ikanow.infinit.e.data_model.index.document.DocumentPojoIndexMap$DocumentPojoSerializer

Copyright © 2018 www.massapicom. 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.