|
19 | 19 | import static org.elasticsearch.index.query.QueryBuilders.*;
|
20 | 20 | import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
21 | 21 |
|
22 |
| -import lombok.Data; |
23 |
| -import lombok.Getter; |
24 |
| -import lombok.Setter; |
25 |
| - |
26 | 22 | import java.util.ArrayList;
|
27 | 23 | import java.util.Arrays;
|
28 | 24 | import java.util.Collection;
|
|
53 | 49 | import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
54 | 50 | import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
55 | 51 | import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
| 52 | +import org.springframework.lang.Nullable; |
56 | 53 | import org.springframework.test.context.ContextConfiguration;
|
57 | 54 |
|
58 | 55 | /**
|
@@ -384,82 +381,238 @@ public void shouldIndexAndSearchMapAsNestedType() {
|
384 | 381 | assertThat(books.getSearchHit(0).getContent().getId()).isEqualTo(book2.getId());
|
385 | 382 | }
|
386 | 383 |
|
387 |
| - @Setter |
388 |
| - @Getter |
389 | 384 | @Document(indexName = "test-index-book-nested-objects", replicas = 0, refreshInterval = "-1")
|
390 | 385 | static class Book {
|
391 | 386 |
|
392 |
| - @Id private String id; |
393 |
| - private String name; |
394 |
| - @Field(type = FieldType.Object) private Author author; |
395 |
| - @Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>(); |
396 |
| - @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), |
| 387 | + @Nullable @Id private String id; |
| 388 | + @Nullable private String name; |
| 389 | + @Nullable @Field(type = FieldType.Object) private Author author; |
| 390 | + @Nullable @Field(type = FieldType.Nested) private Map<Integer, Collection<String>> buckets = new HashMap<>(); |
| 391 | + @Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), |
397 | 392 | otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop",
|
398 | 393 | searchAnalyzer = "standard") }) private String description;
|
| 394 | + |
| 395 | + @Nullable |
| 396 | + public String getId() { |
| 397 | + return id; |
| 398 | + } |
| 399 | + |
| 400 | + public void setId(@Nullable String id) { |
| 401 | + this.id = id; |
| 402 | + } |
| 403 | + |
| 404 | + @Nullable |
| 405 | + public String getName() { |
| 406 | + return name; |
| 407 | + } |
| 408 | + |
| 409 | + public void setName(@Nullable String name) { |
| 410 | + this.name = name; |
| 411 | + } |
| 412 | + |
| 413 | + @Nullable |
| 414 | + public Author getAuthor() { |
| 415 | + return author; |
| 416 | + } |
| 417 | + |
| 418 | + public void setAuthor(@Nullable Author author) { |
| 419 | + this.author = author; |
| 420 | + } |
| 421 | + |
| 422 | + @Nullable |
| 423 | + public Map<Integer, Collection<String>> getBuckets() { |
| 424 | + return buckets; |
| 425 | + } |
| 426 | + |
| 427 | + public void setBuckets(@Nullable Map<Integer, Collection<String>> buckets) { |
| 428 | + this.buckets = buckets; |
| 429 | + } |
| 430 | + |
| 431 | + @Nullable |
| 432 | + public String getDescription() { |
| 433 | + return description; |
| 434 | + } |
| 435 | + |
| 436 | + public void setDescription(@Nullable String description) { |
| 437 | + this.description = description; |
| 438 | + } |
399 | 439 | }
|
400 | 440 |
|
401 |
| - @Data |
402 | 441 | @Document(indexName = "test-index-person", replicas = 0, refreshInterval = "-1")
|
403 | 442 | static class Person {
|
404 |
| - |
405 |
| - @Id private String id; |
406 |
| - |
407 |
| - private String name; |
408 |
| - |
409 |
| - @Field(type = FieldType.Nested) private List<Car> car; |
410 |
| - |
411 |
| - @Field(type = FieldType.Nested, includeInParent = true) private List<Book> books; |
| 443 | + @Nullable @Id private String id; |
| 444 | + @Nullable private String name; |
| 445 | + @Nullable @Field(type = FieldType.Nested) private List<Car> car; |
| 446 | + @Nullable @Field(type = FieldType.Nested, includeInParent = true) private List<Book> books; |
| 447 | + |
| 448 | + @Nullable |
| 449 | + public String getId() { |
| 450 | + return id; |
| 451 | + } |
| 452 | + |
| 453 | + public void setId(@Nullable String id) { |
| 454 | + this.id = id; |
| 455 | + } |
| 456 | + |
| 457 | + @Nullable |
| 458 | + public String getName() { |
| 459 | + return name; |
| 460 | + } |
| 461 | + |
| 462 | + public void setName(@Nullable String name) { |
| 463 | + this.name = name; |
| 464 | + } |
| 465 | + |
| 466 | + @Nullable |
| 467 | + public List<Car> getCar() { |
| 468 | + return car; |
| 469 | + } |
| 470 | + |
| 471 | + public void setCar(@Nullable List<Car> car) { |
| 472 | + this.car = car; |
| 473 | + } |
| 474 | + |
| 475 | + @Nullable |
| 476 | + public List<Book> getBooks() { |
| 477 | + return books; |
| 478 | + } |
| 479 | + |
| 480 | + public void setBooks(@Nullable List<Book> books) { |
| 481 | + this.books = books; |
| 482 | + } |
412 | 483 | }
|
413 | 484 |
|
414 |
| - @Data |
415 | 485 | static class Car {
|
416 |
| - |
417 |
| - private String name; |
418 |
| - private String model; |
| 486 | + @Nullable private String name; |
| 487 | + @Nullable private String model; |
| 488 | + |
| 489 | + @Nullable |
| 490 | + public String getName() { |
| 491 | + return name; |
| 492 | + } |
| 493 | + |
| 494 | + public void setName(String name) { |
| 495 | + this.name = name; |
| 496 | + } |
| 497 | + |
| 498 | + @Nullable |
| 499 | + public String getModel() { |
| 500 | + return model; |
| 501 | + } |
| 502 | + |
| 503 | + public void setModel(String model) { |
| 504 | + this.model = model; |
| 505 | + } |
419 | 506 | }
|
420 | 507 |
|
421 |
| - /** |
422 |
| - * @author Rizwan Idrees |
423 |
| - * @author Mohsin Husen |
424 |
| - * @author Artur Konczak |
425 |
| - */ |
426 |
| - @Data |
427 | 508 | @Document(indexName = "test-index-person-multiple-level-nested", replicas = 0, refreshInterval = "-1")
|
428 | 509 | static class PersonMultipleLevelNested {
|
429 |
| - |
430 |
| - @Id private String id; |
431 |
| - |
432 |
| - private String name; |
433 |
| - |
434 |
| - @Field(type = FieldType.Nested) private List<GirlFriend> girlFriends; |
435 |
| - |
436 |
| - @Field(type = FieldType.Nested) private List<Car> cars; |
437 |
| - |
438 |
| - @Field(type = FieldType.Nested, includeInParent = true) private List<Car> bestCars; |
| 510 | + @Nullable @Id private String id; |
| 511 | + @Nullable private String name; |
| 512 | + @Nullable @Field(type = FieldType.Nested) private List<GirlFriend> girlFriends; |
| 513 | + @Nullable @Field(type = FieldType.Nested) private List<Car> cars; |
| 514 | + @Nullable @Field(type = FieldType.Nested, includeInParent = true) private List<Car> bestCars; |
| 515 | + |
| 516 | + @Nullable |
| 517 | + public String getId() { |
| 518 | + return id; |
| 519 | + } |
| 520 | + |
| 521 | + public void setId(@Nullable String id) { |
| 522 | + this.id = id; |
| 523 | + } |
| 524 | + |
| 525 | + @Nullable |
| 526 | + public String getName() { |
| 527 | + return name; |
| 528 | + } |
| 529 | + |
| 530 | + public void setName(@Nullable String name) { |
| 531 | + this.name = name; |
| 532 | + } |
| 533 | + |
| 534 | + @Nullable |
| 535 | + public List<GirlFriend> getGirlFriends() { |
| 536 | + return girlFriends; |
| 537 | + } |
| 538 | + |
| 539 | + public void setGirlFriends(@Nullable List<GirlFriend> girlFriends) { |
| 540 | + this.girlFriends = girlFriends; |
| 541 | + } |
| 542 | + |
| 543 | + @Nullable |
| 544 | + public List<Car> getCars() { |
| 545 | + return cars; |
| 546 | + } |
| 547 | + |
| 548 | + public void setCars(@Nullable List<Car> cars) { |
| 549 | + this.cars = cars; |
| 550 | + } |
| 551 | + |
| 552 | + @Nullable |
| 553 | + public List<Car> getBestCars() { |
| 554 | + return bestCars; |
| 555 | + } |
| 556 | + |
| 557 | + public void setBestCars(@Nullable List<Car> bestCars) { |
| 558 | + this.bestCars = bestCars; |
| 559 | + } |
439 | 560 | }
|
440 | 561 |
|
441 |
| - /** |
442 |
| - * @author Mohsin Husen |
443 |
| - */ |
444 |
| - @Data |
445 | 562 | static class GirlFriend {
|
446 |
| - |
447 |
| - private String name; |
448 |
| - |
449 |
| - private String type; |
450 |
| - |
451 |
| - @Field(type = FieldType.Nested) private List<Car> cars; |
| 563 | + @Nullable private String name; |
| 564 | + @Nullable private String type; |
| 565 | + @Nullable @Field(type = FieldType.Nested) private List<Car> cars; |
| 566 | + |
| 567 | + @Nullable |
| 568 | + public String getName() { |
| 569 | + return name; |
| 570 | + } |
| 571 | + |
| 572 | + public void setName(@Nullable String name) { |
| 573 | + this.name = name; |
| 574 | + } |
| 575 | + |
| 576 | + @Nullable |
| 577 | + public String getType() { |
| 578 | + return type; |
| 579 | + } |
| 580 | + |
| 581 | + public void setType(@Nullable String type) { |
| 582 | + this.type = type; |
| 583 | + } |
| 584 | + |
| 585 | + @Nullable |
| 586 | + public List<Car> getCars() { |
| 587 | + return cars; |
| 588 | + } |
| 589 | + |
| 590 | + public void setCars(@Nullable List<Car> cars) { |
| 591 | + this.cars = cars; |
| 592 | + } |
452 | 593 | }
|
453 | 594 |
|
454 |
| - /** |
455 |
| - * @author Rizwan Idrees |
456 |
| - * @author Mohsin Husen |
457 |
| - */ |
458 |
| - @Data |
459 | 595 | static class Author {
|
460 |
| - |
461 |
| - private String id; |
462 |
| - private String name; |
| 596 | + @Nullable private String id; |
| 597 | + @Nullable private String name; |
| 598 | + |
| 599 | + @Nullable |
| 600 | + public String getId() { |
| 601 | + return id; |
| 602 | + } |
| 603 | + |
| 604 | + public void setId(@Nullable String id) { |
| 605 | + this.id = id; |
| 606 | + } |
| 607 | + |
| 608 | + @Nullable |
| 609 | + public String getName() { |
| 610 | + return name; |
| 611 | + } |
| 612 | + |
| 613 | + public void setName(@Nullable String name) { |
| 614 | + this.name = name; |
| 615 | + } |
463 | 616 | }
|
464 | 617 |
|
465 | 618 | }
|
0 commit comments