Package org.springframework.data.elasticsearch.entities

Examples of org.springframework.data.elasticsearch.entities.SampleEntity


   */
  @Test
  public void shouldCountCustomMethodForNotIn() {
    // given
    String documentId = randomNumeric(5);
    SampleEntity sampleEntity = new SampleEntity();
    sampleEntity.setId(documentId);
    sampleEntity.setType("test");
    sampleEntity.setMessage("foo");
    repository.save(sampleEntity);

    // given
    String documentId2 = randomNumeric(5);
    SampleEntity sampleEntity2 = new SampleEntity();
    sampleEntity2.setId(documentId2);
    sampleEntity2.setType("test");
    sampleEntity2.setMessage("bar");
    repository.save(sampleEntity2);

    List<String> ids = Arrays.asList(documentId);

    // when
View Full Code Here


   */
  @Test
  public void shouldCountCustomMethodForTrue() {
    // given
    String documentId = randomNumeric(5);
    SampleEntity sampleEntity = new SampleEntity();
    sampleEntity.setId(documentId);
    sampleEntity.setType("test");
    sampleEntity.setMessage("foo");
    sampleEntity.setAvailable(true);
    repository.save(sampleEntity);

    // given
    String documentId2 = randomNumeric(5);
    SampleEntity sampleEntity2 = new SampleEntity();
    sampleEntity2.setId(documentId2);
    sampleEntity2.setType("test");
    sampleEntity2.setMessage("bar");
    sampleEntity2.setAvailable(false);
    repository.save(sampleEntity2);
    // when
    long count = repository.countByAvailableTrue();
    // then
    assertThat(count, is(equalTo(1L)));
View Full Code Here

    //when
    elasticsearchTemplate.addAlias(aliasQuery);

    String documentId = randomNumeric(5);
    SampleEntity sampleEntity = new SampleEntityBuilder(documentId)
        .message("some message")
        .version(System.currentTimeMillis()).build();

    IndexQuery indexQuery = new IndexQueryBuilder()
        .withIndexName(alias)
        .withId(sampleEntity.getId())
        .withType(TYPE_NAME)
        .withObject(sampleEntity)
        .build();

    elasticsearchTemplate.index(indexQuery);
View Full Code Here

    //when
    elasticsearchTemplate.addAlias(aliasQuery1);
    elasticsearchTemplate.addAlias(aliasQuery2);

    String documentId = randomNumeric(5);
    SampleEntity sampleEntity = new SampleEntityBuilder(documentId)
        .message("some message")
        .version(System.currentTimeMillis()).build();

    IndexQuery indexQuery = new IndexQueryBuilder()
        .withIndexName(alias1)
        .withType(TYPE_NAME)
        .withId(sampleEntity.getId())
        .withObject(sampleEntity).build();

    elasticsearchTemplate.index(indexQuery);
    elasticsearchTemplate.refresh(SampleEntity.class, true);
View Full Code Here

   */
  @Test
  public void shouldCountCustomMethodForFalse() {
    // given
    String documentId = randomNumeric(5);
    SampleEntity sampleEntity = new SampleEntity();
    sampleEntity.setId(documentId);
    sampleEntity.setType("test");
    sampleEntity.setMessage("foo");
    sampleEntity.setAvailable(true);
    repository.save(sampleEntity);

    // given
    String documentId2 = randomNumeric(5);
    SampleEntity sampleEntity2 = new SampleEntity();
    sampleEntity2.setId(documentId2);
    sampleEntity2.setType("test");
    sampleEntity2.setMessage("bar");
    sampleEntity2.setAvailable(false);
    repository.save(sampleEntity2);
    // when
    long count = repository.countByAvailableFalse();
    // then
    assertThat(count, is(equalTo(1L)));
View Full Code Here

   */
  @Test
  public void shouldCountCustomMethodWithWithinGeoPoint() {
    // given
    String documentId = randomNumeric(5);
    SampleEntity sampleEntity = new SampleEntity();
    sampleEntity.setId(documentId);
    sampleEntity.setType("test");
    sampleEntity.setRate(10);
    sampleEntity.setMessage("foo");
    sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));

    repository.save(sampleEntity);

    documentId = randomNumeric(5);
    SampleEntity sampleEntity2 = new SampleEntity();
    sampleEntity2.setId(documentId);
    sampleEntity2.setType("test");
    sampleEntity2.setRate(10);
    sampleEntity2.setMessage("foo");
    sampleEntity2.setLocation(new GeoPoint(30.7806d, 0.0875d));

    repository.save(sampleEntity2);

    // when
    long count = repository.countByLocationWithin(new GeoPoint(45.7806d, 3.0875d), "2km");
View Full Code Here

   */
  @Test
  public void shouldCountCustomMethodWithWithinPoint() {
    // given
    String documentId = randomNumeric(5);
    SampleEntity sampleEntity = new SampleEntity();
    sampleEntity.setId(documentId);
    sampleEntity.setType("test");
    sampleEntity.setRate(10);
    sampleEntity.setMessage("foo");
    sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));

    repository.save(sampleEntity);

    documentId = randomNumeric(5);
    SampleEntity sampleEntity2 = new SampleEntity();
    sampleEntity2.setId(documentId);
    sampleEntity2.setType("test");
    sampleEntity2.setRate(10);
    sampleEntity2.setMessage("foo");
    sampleEntity2.setLocation(new GeoPoint(30.7806d, 0.0875d));

    repository.save(sampleEntity2);

    // when
    long count = repository.countByLocationWithin(new Point(3.0875d, 45.7806d), new Distance(2, Metrics.KILOMETERS));
View Full Code Here

   */
  @Test
  public void shouldCountCustomMethodWithNearBox() {
    // given
    String documentId = randomNumeric(5);
    SampleEntity sampleEntity = new SampleEntity();
    sampleEntity.setId(documentId);
    sampleEntity.setType("test");
    sampleEntity.setRate(10);
    sampleEntity.setMessage("foo");
    sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));

    repository.save(sampleEntity);

    documentId = randomNumeric(5);
    SampleEntity sampleEntity2 = new SampleEntity();
    sampleEntity2.setId(documentId);
    sampleEntity2.setType("test2");
    sampleEntity2.setRate(10);
    sampleEntity2.setMessage("foo");
    sampleEntity2.setLocation(new GeoPoint(30.7806d, 0.0875d));

    repository.save(sampleEntity2);

    // when
    long count = repository.countByLocationNear(new Box(new Point(3d, 46d), new Point(4d, 45d)));
View Full Code Here

   */
  @Test
  public void shouldCountCustomMethodWithNearPointAndDistance() {
    // given
    String documentId = randomNumeric(5);
    SampleEntity sampleEntity = new SampleEntity();
    sampleEntity.setId(documentId);
    sampleEntity.setType("test");
    sampleEntity.setRate(10);
    sampleEntity.setMessage("foo");
    sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));

    repository.save(sampleEntity);

    documentId = randomNumeric(5);
    SampleEntity sampleEntity2 = new SampleEntity();
    sampleEntity2.setId(documentId);
    sampleEntity2.setType("test");
    sampleEntity2.setRate(10);
    sampleEntity2.setMessage("foo");
    sampleEntity2.setLocation(new GeoPoint(30.7806d, 0.0875d));

    repository.save(sampleEntity2);

    // when
    long count = repository.countByLocationNear(new Point(3.0875d, 45.7806d), new Distance(2, Metrics.KILOMETERS));
View Full Code Here

  @Test
  public void shouldSaveIterableEntities() {
    // given
    String documentId = randomNumeric(5);
    SampleEntity sampleEntity1 = new SampleEntity();
    sampleEntity1.setId(documentId);
    sampleEntity1.setMessage("hello world.");
    sampleEntity1.setVersion(System.currentTimeMillis());

    String documentId2 = randomNumeric(5);
    SampleEntity sampleEntity2 = new SampleEntity();
    sampleEntity2.setId(documentId2);
    sampleEntity2.setMessage("hello world.");
    sampleEntity2.setVersion(System.currentTimeMillis());

    Iterable<SampleEntity> sampleEntities = Arrays.asList(sampleEntity1, sampleEntity2);
    // when
    repository.save(sampleEntities);
    // then
View Full Code Here

TOP

Related Classes of org.springframework.data.elasticsearch.entities.SampleEntity

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.