Hello All,
I have a very simple use case, in which I have some Places
and some Users
who can write some Reviews
.
I have implemented the code using java
, springboot
and mongodb
. Here are my main classes:
@Document(collection = "user")
public class User {
@Id
private String id;
@Indexed(unique = true, direction = IndexDirection.DESCENDING, dropDups = true)
private String email;
private String password;
private String fullname;
private byte[] image;
private String imagename;
private boolean enabled;
@DBRef
private Set<Role> roles;
private String firstname;
private String lastname;
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
private Date lastPasswordResetDate;
}
Here is the place class:
@Document(collection = "place")
public class Place {
public Place() {}
private String place_name;
@Id
private String id;
private Double longitude;
private Double latitude;
private String municipalitySubdivision;
private String municipality;
private String countrySecondarySubdivision;
private String countryTertiarySubdivision;
private String countrySubdivision;
private String country;
private String category;
}
and here is the review class:
@Document(collection = "review")
public class Review {
public Review() {
}
@Id
private String id;
@TextIndexed(weight=7)
private String first_point;
@TextIndexed(weight=6)
private String second_point;
@TextIndexed(weight=5)
private String third_point;
@TextIndexed(weight=4)
private String fourth_point;
@TextIndexed(weight=3)
private String fifth_point;
@TextIndexed(weight=2)
private String sixth_point;
@TextIndexed(weight=1)
private String seventh_point;
private Place place;
@DBRef
private User user;
private String date;
@TextScore
private Float textScore;
}
Here is my Role class:
@Document(collection = "role")
public class Role {
@Id
private String id;
@Indexed(unique = true, direction = IndexDirection.DESCENDING, dropDups = true)
private String role;
}
In this project, the review is not a simple text, but is composed of multiple texts which have different weights.
the user can search for a keyword and the reviews which are more relevant are sorted according to the their scores.
As I am totally new to mongodb, I have read the documentations about DBRef, Textscore, etc. and have designed it as mentioned. I am wondering if I have used them correctly and my implementation is reasonable or if I have to make big changes to it.
I should also mention that the code works without any problem, but I am wondering if it will also work when it is live as a web page and many users want to use it at the same time.
Your help would be appreciated.