Package org.elasticsearchfr.handson.beans

Examples of org.elasticsearchfr.handson.beans.Beer


    ObjectMapper mapper = new ObjectMapper();

    BulkRequestBuilder brb = node.client().prepareBulk();

    for (int i = 0; i < 1000; i++) {
      Beer beer = BeerHelper.generate();
      IndexRequest irq = new IndexRequest("meal", "beer", "beer_" + i);
      String jsonString = mapper.writeValueAsString(beer);
      irq.source(jsonString);
      brb.add(irq);
    }
View Full Code Here


      ExecutionException {

    // instance a json mapper
    ObjectMapper mapper = new ObjectMapper(); // create once, reuse

    Beer beer = new Beer("Heineken", Colour.PALE, 0.33, 3);
    IndexResponse ir = null;

    // generate a json content
    String jsonString = null;
    // TODO Serialize Beer to json

    // indexing document
    // TODO index the beer in meal index, beer type

    Assert.assertNotNull(ir);
    Assert.assertNotNull(ir.getId());

    GetResponse gr = null;
    // TODO get the beer we have just indexed

    Assert.assertNotNull(gr);
    Assert.assertNotNull(gr.getId());

    // We check that id are equals
    Assert.assertEquals(ir.getId(), gr.getId());

    Beer indexedBeer = null;
   
    // TODO Deserialize json indexed beer into a beer object

    Assert.assertNotNull(indexedBeer);
    Assert.assertEquals(beer, indexedBeer);
View Full Code Here

    BulkRequestBuilder brb = null;
   
    // TODO Create the bulk
    brb = node.client().prepareBulk();
    for (int i = 0; i < 1000; i++) {
      Beer beer = BeerHelper.generate();
      IndexRequest irq =  null;
     
      // TODO Add the beer to meal index, type beer and set id = "beer_"+i
    }
    BulkResponse br = null;
View Full Code Here

    ObjectMapper mapper = new ObjectMapper();

    BulkRequestBuilder brb = node.client().prepareBulk();

    for (int i = 0; i < 1000; i++) {
      Beer beer = BeerHelper.generate();
      IndexRequest irq = new IndexRequest("meal", "beer", "beer_" + i);
      String jsonString = mapper.writeValueAsString(beer);
      irq.source(jsonString);
      brb.add(irq);
    }
View Full Code Here

    Assert.assertTrue(sr.getHits().getTotalHits() > 0);

    logger.info("We found {} beers", sr.getHits().totalHits());

    for (SearchHit hit : sr.getHits()) {
      Beer beer = BeerHelper.toBeer(hit.getSourceAsString());
      Assert.assertEquals("Heineken", beer.getBrand());
      Assert.assertTrue(beer.getPrice()>5 && beer.getPrice()<10);
    }
  }
View Full Code Here

    Assert.assertTrue(sr.getHits().getTotalHits() > 0);

    logger.info("We found {} beers", sr.getHits().totalHits());
   
    for (SearchHit hit : sr.getHits()) {
      Beer beer = BeerHelper.toBeer(hit.getSourceAsString());
      Assert.assertEquals("Heineken", beer.getBrand());
      Assert.assertTrue(beer.getPrice()>5 && beer.getPrice()<10);
      Assert.assertTrue(beer.getSize()>1);
    }

    logger.info("Full json result is: {}", sr.toString());
  }
View Full Code Here

    logger.info("We found {} beers", sr.getHits().totalHits());
   
    int nbHeineken = 0;
    int nbPale = 0;
    for (SearchHit hit : sr.getHits()) {
      Beer beer = BeerHelper.toBeer(hit.getSourceAsString());

      if ("Heineken".equals(beer.getBrand())) nbHeineken++;
      if (Colour.PALE.equals(beer.getColour())) nbPale++;
    }
   
    logger.info("For the first 100 beers, we have {} Heineken and {} pale beers", nbHeineken, nbPale);
    logger.info("Full json result is: {}", sr.toString());
   
View Full Code Here

    logger.info("We found {} beers", sr.getHits().totalHits());
   
    int nbHeineken = 0;
    int nbPale = 0;
    for (SearchHit hit : sr.getHits()) {
      Beer beer = BeerHelper.toBeer(hit.getSourceAsString());

      if ("Heineken".equals(beer.getBrand())) nbHeineken++;
      if (Colour.PALE.equals(beer.getColour())) nbPale++;
    }
   
    logger.info("For the first 100 beers, we have {} Heineken and {} pale beers", nbHeineken, nbPale);
   
    // We expect to have more or equals pale beers than heineken
View Full Code Here

TOP

Related Classes of org.elasticsearchfr.handson.beans.Beer

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.