|
| 1 | +package net.aimeizi.spring.data.elasticsearch.example; |
| 2 | + |
| 3 | +import org.springframework.data.annotation.Id; |
| 4 | +import org.springframework.data.elasticsearch.annotations.Document; |
| 5 | +import org.springframework.data.elasticsearch.annotations.Field; |
| 6 | +import org.springframework.data.elasticsearch.annotations.FieldIndex; |
| 7 | +import org.springframework.data.elasticsearch.annotations.FieldType; |
| 8 | + |
| 9 | + |
| 10 | +@Document(indexName= "book", type= "book", indexStoreType = /*"fs"*/"memory", shards = 1, replicas = 0, refreshInterval = "-1") |
| 11 | +public class Book{ |
| 12 | + |
| 13 | + @Id |
| 14 | + private Integer id; |
| 15 | + private String name; |
| 16 | + private String desc; |
| 17 | + @Field(index=FieldIndex.not_analyzed) |
| 18 | + private String url; |
| 19 | + @Field(index=FieldIndex.not_analyzed) |
| 20 | + private String pubdate; |
| 21 | + private String pubinfo; |
| 22 | + @Field(type=FieldType.Nested) |
| 23 | + private Author author; |
| 24 | + @Field(type=FieldType.Float,index=FieldIndex.not_analyzed) |
| 25 | + private Double price; |
| 26 | + |
| 27 | + public Book() { |
| 28 | + |
| 29 | + } |
| 30 | + |
| 31 | + public Book(Integer id, String name, String desc, String url, String pubdate, |
| 32 | + String pubinfo, Author author, Double price) { |
| 33 | + super(); |
| 34 | + this.id = id; |
| 35 | + this.name = name; |
| 36 | + this.desc = desc; |
| 37 | + this.url = url; |
| 38 | + this.pubdate = pubdate; |
| 39 | + this.pubinfo = pubinfo; |
| 40 | + this.author = author; |
| 41 | + this.price = price; |
| 42 | + } |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + public Integer getId() { |
| 47 | + return id; |
| 48 | + } |
| 49 | + public void setId(Integer id) { |
| 50 | + this.id = id; |
| 51 | + } |
| 52 | + public String getName() { |
| 53 | + return name; |
| 54 | + } |
| 55 | + public void setName(String name) { |
| 56 | + this.name = name; |
| 57 | + } |
| 58 | + |
| 59 | + public String getDesc() { |
| 60 | + return desc; |
| 61 | + } |
| 62 | + |
| 63 | + public void setDesc(String desc) { |
| 64 | + this.desc = desc; |
| 65 | + } |
| 66 | + |
| 67 | + public String getUrl() { |
| 68 | + return url; |
| 69 | + } |
| 70 | + public void setUrl(String url) { |
| 71 | + this.url = url; |
| 72 | + } |
| 73 | + public String getPubdate() { |
| 74 | + return pubdate; |
| 75 | + } |
| 76 | + public void setPubdate(String pubdate) { |
| 77 | + this.pubdate = pubdate; |
| 78 | + } |
| 79 | + |
| 80 | + public String getPubinfo() { |
| 81 | + return pubinfo; |
| 82 | + } |
| 83 | + |
| 84 | + public void setPubinfo(String pubinfo) { |
| 85 | + this.pubinfo = pubinfo; |
| 86 | + } |
| 87 | + |
| 88 | + public Author getAuthor() { |
| 89 | + return author; |
| 90 | + } |
| 91 | + public void setAuthor(Author author) { |
| 92 | + this.author = author; |
| 93 | + } |
| 94 | + |
| 95 | + public Double getPrice() { |
| 96 | + return price; |
| 97 | + } |
| 98 | + |
| 99 | + public void setPrice(Double price) { |
| 100 | + this.price = price; |
| 101 | + } |
| 102 | + |
| 103 | + @Override |
| 104 | + public String toString() { |
| 105 | + return "Book [id=" + id + ", name=" + name + ", desc=" + desc |
| 106 | + + ", url=" + url + ", pubdate=" + pubdate + ", pubinfo=" |
| 107 | + + pubinfo + ", author=" + author + ", price=" + price + "]"; |
| 108 | + } |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | +} |
0 commit comments