diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Record.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Record.java index 38a94d02bc2b01742a1c2e8f4e6bbcce5ec48d9e..f93951c16f2c12f6d31fd1b75734996efc1f66a3 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Record.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Record.java @@ -30,11 +30,13 @@ import org.duniter.core.client.model.local.LocalEntity; */ public class Record implements LocalEntity<String> { + public static final String PROPERTY_VERSION="version"; public static final String PROPERTY_ISSUER="issuer"; public static final String PROPERTY_HASH="hash"; public static final String PROPERTY_SIGNATURE="signature"; public static final String PROPERTY_TIME="time"; + private String version; private String id; private String issuer; private String hash; @@ -45,6 +47,7 @@ public class Record implements LocalEntity<String> { } public Record(Record another) { + this.version = another.getVersion(); this.id = another.getId(); this.issuer = another.getIssuer(); this.hash = another.getHash(); @@ -52,6 +55,14 @@ public class Record implements LocalEntity<String> { this.time = another.getTime(); } + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + @JsonIgnore public String getId() { return id; diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Records.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Records.java index 0fbc3c9322ada2f601c2ca2f41c43dc1dfbbf4e6..23198ee37d03aa27e54f186e16e95dccfadc467f 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Records.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/Records.java @@ -28,12 +28,39 @@ package org.duniter.core.client.model.elasticsearch; */ public final class Records { + // Common fields public static final String PROPERTY_ISSUER="issuer"; public static final String PROPERTY_HASH="hash"; public static final String PROPERTY_SIGNATURE="signature"; public static final String PROPERTY_VERSION="version"; public static final String PROPERTY_TIME="time"; + public static final String PROPERTY_CREATION_TIME="creationTime"; + + // Read marker public static final String PROPERTY_READ_SIGNATURE="read_signature"; + // Location + public static final String PROPERTY_ADDRESS="address"; + public static final String PROPERTY_CITY="city"; + public static final String PROPERTY_GEO_POINT="geoPoint"; + + // record + public static final String PROPERTY_TITLE="title"; + public static final String PROPERTY_DESCRIPTION="description"; + + // Avatar & pictures + public static final String PROPERTY_AVATAR="avatar"; + public static final String PROPERTY_PICTURES="pictures"; + public static final String PROPERTY_PICTURES_COUNT="picturesCount"; + + // Socials & tags + public static final String PROPERTY_SOCIALS="socials"; + public static final String PROPERTY_TAGS="tags"; + + // Other + public static final String PROPERTY_CATEGORY="category"; + public static final String PROPERTY_CONTENT="content"; + + } diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/UserProfile.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/UserProfile.java index e9efcdc4b3a42cc90948b5aa5080ea43b8eeccdd..dca4bc89951f1e314584c0695a64d3a6998863b2 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/UserProfile.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/elasticsearch/UserProfile.java @@ -29,12 +29,14 @@ public class UserProfile extends Record { public static final String PROPERTY_TITLE = "title"; public static final String PROPERTY_DESCRIPTION="description"; + public static final String PROPERTY_ADDRESS="address"; public static final String PROPERTY_CITY="city"; public static final String PROPERTY_EMAIL="email"; public static final String PROPERTY_LOCALE="locale"; private String title; private String description; + private String address; private String email; private String locale; @@ -69,4 +71,12 @@ public class UserProfile extends Record { public void setLocale(String locale) { this.locale = locale; } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } } diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Peer.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Peer.java index 419608bc394ca865d3fee28d6ec70ff433a9fe6d..d2e2c649cd54b577a3346a96ad3c02d6d7b53f2e 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Peer.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/local/Peer.java @@ -403,6 +403,7 @@ public class Peer implements LocalEntity<String>, Serializable { } public static class Stats { + public static final String PROPERTY_VERSION = "version"; public static final String PROPERTY_STATUS = "status"; public static final String PROPERTY_LAST_UP_TIME = "lastUpTime"; public static final String PROPERTY_UID = "uid"; diff --git a/duniter4j-es-assembly/src/test/es-home/config/elasticsearch.yml b/duniter4j-es-assembly/src/test/es-home/config/elasticsearch.yml index 553a93e4208a2b54dcd09bbfca05a2ac812c620d..0759654b4ca087fb75716a16ed3cf043535e28c1 100644 --- a/duniter4j-es-assembly/src/test/es-home/config/elasticsearch.yml +++ b/duniter4j-es-assembly/src/test/es-home/config/elasticsearch.yml @@ -14,7 +14,7 @@ # # Use a descriptive name for your cluster: # -cluster.name: g1-es-data +cluster.name: g1-es-data-test # # ------------------------------------ Node ------------------------------------ # @@ -180,16 +180,14 @@ duniter.p2p.discovery.enable: false # duniter.p2p.includes.endpoints: [ "ES_USER_API g1.data.duniter.fr 443", - "ES_SUBSCRIPTION_API g1.data.duniter.fr 443", - "ES_USER_API g1.data.le-sou.org 443", - "ES_SUBSCRIPTION_API g1.data.le-sou.org 443" + "ES_SUBSCRIPTION_API g1.data.duniter.fr 443" ] # # Pass a list of pubkeys to always synchronize (default: <empty>) # -duniter.p2p.includes.pubkeys: [ - "38MEAZN68Pz1DTvT3tqgxx4yQP6snJCQhPqEFxbDk4aE" -] +#duniter.p2p.includes.pubkeys: [ +# "38MEAZN68Pz1DTvT3tqgxx4yQP6snJCQhPqEFxbDk4aE" +#] #duniter.p2p.fullResyncAtStartup: true # # ---------------------------------- Duniter4j Mail module ----------------------- diff --git a/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/dao/impl/PeerDaoImpl.java b/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/dao/impl/PeerDaoImpl.java index 0911dbc757d4a7fb383200cf9411efa2679ec391..dcf605ec017c139946c16e388eb867ab1d945335 100644 --- a/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/dao/impl/PeerDaoImpl.java +++ b/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/dao/impl/PeerDaoImpl.java @@ -373,7 +373,7 @@ public class PeerDaoImpl extends AbstractDao implements PeerDao { .startObject("properties") // stats.version - .startObject("version") + .startObject(Peer.Stats.PROPERTY_VERSION) .field("type", "string") .endObject() diff --git a/duniter4j-es-subscription/src/main/java/org/duniter/elasticsearch/subscription/dao/record/SubscriptionRecordDaoImpl.java b/duniter4j-es-subscription/src/main/java/org/duniter/elasticsearch/subscription/dao/record/SubscriptionRecordDaoImpl.java index e5fa09ddc96ce44b70e9ff677302818b69c0bbec..7ad0fe863fab6aabff575f8a94e74db422a52d22 100644 --- a/duniter4j-es-subscription/src/main/java/org/duniter/elasticsearch/subscription/dao/record/SubscriptionRecordDaoImpl.java +++ b/duniter4j-es-subscription/src/main/java/org/duniter/elasticsearch/subscription/dao/record/SubscriptionRecordDaoImpl.java @@ -22,6 +22,7 @@ package org.duniter.elasticsearch.subscription.dao.record; * #L% */ +import org.duniter.core.client.model.elasticsearch.Record; import org.duniter.core.exception.TechnicalException; import org.duniter.core.util.CollectionUtils; import org.duniter.elasticsearch.subscription.PluginSettings; @@ -86,54 +87,64 @@ public class SubscriptionRecordDaoImpl extends AbstractSubscriptionIndexTypeDao< .startObject(getType()) .startObject("properties") + // version + .startObject(SubscriptionRecord.PROPERTY_VERSION) + .field("type", "integer") + .endObject() + + // type + .startObject(SubscriptionRecord.PROPERTY_TYPE) + .field("type", "string") + .field("index", "not_analyzed") + .endObject() + // issuer - .startObject("issuer") + .startObject(SubscriptionRecord.PROPERTY_ISSUER) .field("type", "string") .field("index", "not_analyzed") .endObject() // recipient - .startObject("recipient") + .startObject(SubscriptionRecord.PROPERTY_RECIPIENT) .field("type", "string") .field("index", "not_analyzed") .endObject() // time - .startObject("time") + .startObject(SubscriptionRecord.PROPERTY_TIME) .field("type", "integer") .endObject() // nonce - .startObject("nonce") + .startObject(SubscriptionRecord.PROPERTY_NONCE) .field("type", "string") .field("index", "not_analyzed") .endObject() - // issuer content - .startObject("issuer_content") + // issuerContent + .startObject(SubscriptionRecord.PROPERTY_ISSUER_CONTENT) .field("type", "string") .field("index", "not_analyzed") .endObject() // receiver content - .startObject("receiver_content") + .startObject(SubscriptionRecord.PROPERTY_RECIPIENT_CONTENT) .field("type", "string") .field("index", "not_analyzed") .endObject() // hash - .startObject("hash") + .startObject(SubscriptionRecord.PROPERTY_HASH) .field("type", "string") .field("index", "not_analyzed") .endObject() // signature - .startObject("signature") + .startObject(SubscriptionRecord.PROPERTY_SIGNATURE) .field("type", "string") .field("index", "not_analyzed") .endObject() - .endObject() .endObject().endObject(); diff --git a/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/dao/AbstractCommentDaoImpl.java b/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/dao/AbstractCommentDaoImpl.java index 0304e2800f499c2a50643a3748c96935cf2f7067..640921131099ffc3641d9ba8c1a16c3ef8cc04ca 100644 --- a/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/dao/AbstractCommentDaoImpl.java +++ b/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/dao/AbstractCommentDaoImpl.java @@ -24,7 +24,9 @@ package org.duniter.elasticsearch.user.dao; import com.fasterxml.jackson.core.JsonProcessingException; +import org.duniter.core.client.model.elasticsearch.Record; import org.duniter.core.client.model.elasticsearch.RecordComment; +import org.duniter.core.client.model.elasticsearch.Records; import org.duniter.core.exception.TechnicalException; import org.duniter.elasticsearch.dao.AbstractIndexTypeDao; import org.duniter.elasticsearch.user.PluginSettings; @@ -100,19 +102,24 @@ public class AbstractCommentDaoImpl<T extends AbstractCommentDaoImpl> extends Ab XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject(getType()) .startObject("properties") + // version + .startObject(Record.PROPERTY_VERSION) + .field("type", "integer") + .endObject() + // issuer - .startObject("issuer") + .startObject(Record.PROPERTY_ISSUER) .field("type", "string") .field("index", "not_analyzed") .endObject() // creationTime - .startObject("creationTime") + .startObject(Records.PROPERTY_CREATION_TIME) .field("type", "integer") .endObject() // time - .startObject("time") + .startObject(Record.PROPERTY_TIME) .field("type", "integer") .endObject() diff --git a/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/dao/AbstractRecordDaoImpl.java b/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/dao/AbstractRecordDaoImpl.java index b71b4872eaaf0b3015e8c909509290d4e2046aef..c1428cbe3f1ed466db402340873065cedecd85de 100644 --- a/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/dao/AbstractRecordDaoImpl.java +++ b/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/dao/AbstractRecordDaoImpl.java @@ -25,6 +25,8 @@ package org.duniter.elasticsearch.user.dao; import com.fasterxml.jackson.core.JsonProcessingException; import org.duniter.core.client.model.elasticsearch.Record; +import org.duniter.core.client.model.elasticsearch.Records; +import org.duniter.elasticsearch.user.model.UserProfile; import org.duniter.core.exception.TechnicalException; import org.duniter.core.util.ObjectUtils; import org.duniter.elasticsearch.dao.AbstractIndexTypeDao; @@ -74,20 +76,25 @@ public class AbstractRecordDaoImpl<T extends AbstractRecordDaoImpl> extends Abst XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject(getType()) .startObject("properties") + // version + .startObject(Record.PROPERTY_VERSION) + .field("type", "integer") + .endObject() + // title - .startObject("title") + .startObject(Records.PROPERTY_TITLE) .field("type", "string") .field("analyzer", stringAnalyzer) .endObject() // description - .startObject("description") + .startObject(Records.PROPERTY_DESCRIPTION) .field("type", "string") .field("analyzer", stringAnalyzer) .endObject() // creationTime - .startObject("creationTime") + .startObject(Records.PROPERTY_CREATION_TIME) .field("type", "integer") .endObject() @@ -115,23 +122,23 @@ public class AbstractRecordDaoImpl<T extends AbstractRecordDaoImpl> extends Abst .endObject() // address - .startObject("address") + .startObject(Records.PROPERTY_ADDRESS) .field("type", "string") .field("analyzer", stringAnalyzer) .endObject() // city - .startObject("city") + .startObject(Records.PROPERTY_CITY) .field("type", "string") .endObject() // geoPoint - .startObject("geoPoint") + .startObject(Records.PROPERTY_GEO_POINT) .field("type", "geo_point") .endObject() // avatar - .startObject("avatar") + .startObject(Records.PROPERTY_AVATAR) .field("type", "attachment") .startObject("fields") // fields .startObject("content") // content @@ -151,7 +158,7 @@ public class AbstractRecordDaoImpl<T extends AbstractRecordDaoImpl> extends Abst .endObject() // social networks - .startObject("socials") + .startObject(Records.PROPERTY_SOCIALS) .field("type", "nested") .field("dynamic", "false") .startObject("properties") @@ -167,7 +174,7 @@ public class AbstractRecordDaoImpl<T extends AbstractRecordDaoImpl> extends Abst .endObject() // tags - .startObject("tags") + .startObject(Records.PROPERTY_TAGS) .field("type", "completion") .field("search_analyzer", "simple") .field("analyzer", "simple") @@ -184,7 +191,7 @@ public class AbstractRecordDaoImpl<T extends AbstractRecordDaoImpl> extends Abst // pictures if (isNestedPicturesEnable) { - mapping.startObject("pictures") + mapping.startObject(Records.PROPERTY_PICTURES) .field("type", "nested") .field("dynamic", "false") .startObject("properties") @@ -212,14 +219,14 @@ public class AbstractRecordDaoImpl<T extends AbstractRecordDaoImpl> extends Abst .endObject() // picturesCount - .startObject("picturesCount") + .startObject(Records.PROPERTY_PICTURES_COUNT) .field("type", "integer") .endObject(); } // category if (isNestedCategoryEnable) { - mapping.startObject("category") + mapping.startObject(Records.PROPERTY_CATEGORY) .field("type", "nested") .field("dynamic", "false") .startObject("properties") diff --git a/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/dao/profile/UserProfileDaoImpl.java b/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/dao/profile/UserProfileDaoImpl.java index 8ce2f972d66cfb705ba3a78ddbd0a718f8469036..a2af79827f25b2128c0dde1e910dc06a3fc4f2f3 100644 --- a/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/dao/profile/UserProfileDaoImpl.java +++ b/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/dao/profile/UserProfileDaoImpl.java @@ -25,12 +25,14 @@ package org.duniter.elasticsearch.user.dao.profile; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import org.duniter.core.client.model.elasticsearch.Record; +import org.duniter.core.client.model.elasticsearch.Records; import org.duniter.core.exception.TechnicalException; import org.duniter.core.util.ObjectUtils; import org.duniter.core.util.Preconditions; import org.duniter.elasticsearch.dao.AbstractIndexTypeDao; import org.duniter.elasticsearch.exception.InvalidFormatException; import org.duniter.elasticsearch.user.PluginSettings; +import org.duniter.elasticsearch.user.model.UserProfile; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -96,46 +98,51 @@ public class UserProfileDaoImpl extends AbstractIndexTypeDao<UserProfileDaoImpl> XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject(getType()) .startObject("properties") + // version + .startObject(UserProfile.PROPERTY_VERSION) + .field("type", "integer") + .endObject() + // title - .startObject("title") + .startObject(UserProfile.PROPERTY_TITLE) .field("type", "string") .field("analyzer", stringAnalyzer) .endObject() // description - .startObject("description") + .startObject(UserProfile.PROPERTY_DESCRIPTION) .field("type", "string") .field("analyzer", stringAnalyzer) .endObject() // time - .startObject("time") + .startObject(UserProfile.PROPERTY_TIME) .field("type", "integer") .endObject() // issuer - .startObject("issuer") + .startObject(UserProfile.PROPERTY_ISSUER) .field("type", "string") .field("index", "not_analyzed") .endObject() // city - .startObject("city") + .startObject(UserProfile.PROPERTY_CITY) .field("type", "string") .endObject() // address - .startObject("address") + .startObject(UserProfile.PROPERTY_ADDRESS) .field("type", "string") .endObject() // geoPoint - .startObject("geoPoint") + .startObject(Records.PROPERTY_GEO_POINT) .field("type", "geo_point") .endObject() // avatar - .startObject("avatar") + .startObject(Records.PROPERTY_AVATAR) .field("type", "attachment") .startObject("fields") // fields .startObject("content") // content @@ -155,7 +162,7 @@ public class UserProfileDaoImpl extends AbstractIndexTypeDao<UserProfileDaoImpl> .endObject() // social networks - .startObject("socials") + .startObject(Records.PROPERTY_SOCIALS) .field("type", "nested") .field("dynamic", "false") .startObject("properties") @@ -171,7 +178,7 @@ public class UserProfileDaoImpl extends AbstractIndexTypeDao<UserProfileDaoImpl> .endObject() // tags - .startObject("tags") + .startObject(Records.PROPERTY_TAGS) .field("type", "completion") .field("search_analyzer", "simple") .field("analyzer", "simple") diff --git a/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/dao/profile/UserSettingsDaoImpl.java b/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/dao/profile/UserSettingsDaoImpl.java index 77e6c09668d9a8b6da071f001d75deb32594e376..57e3d14b1d82f30bcb74bc8bbb00e753f608c54d 100644 --- a/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/dao/profile/UserSettingsDaoImpl.java +++ b/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/dao/profile/UserSettingsDaoImpl.java @@ -92,13 +92,18 @@ public class UserSettingsDaoImpl extends AbstractIndexTypeDao<UserSettingsDaoImp XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject(getType()) .startObject("properties") + // version + .startObject(Record.PROPERTY_VERSION) + .field("type", "integer") + .endObject() + // time - .startObject("time") + .startObject(Record.PROPERTY_TIME) .field("type", "integer") .endObject() // issuer - .startObject("issuer") + .startObject(Record.PROPERTY_ISSUER) .field("type", "string") .field("index", "not_analyzed") .endObject() diff --git a/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/model/UserProfile.java b/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/model/UserProfile.java index 73ad472a7312f6173c6a1db8f3ce86bccfa4d266..6ef6ecb0cc217f821fb3399e98370fbc4f8f8371 100644 --- a/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/model/UserProfile.java +++ b/duniter4j-es-user/src/main/java/org/duniter/elasticsearch/user/model/UserProfile.java @@ -31,15 +31,18 @@ public class UserProfile extends Record { public static final String PROPERTY_TITLE = "title"; public static final String PROPERTY_DESCRIPTION="description"; - public static final String PROPERTY_CITY="city"; public static final String PROPERTY_EMAIL="email"; public static final String PROPERTY_LOCALE="locale"; public static final String PROPERTY_AVATAR="avatar"; + public static final String PROPERTY_ADDRESS="address"; + public static final String PROPERTY_CITY="city"; private String title; private String description; private String email; private String locale; + private String address; + private String city; public String getTitle() { return title; @@ -72,4 +75,20 @@ public class UserProfile extends Record { public void setLocale(String locale) { this.locale = locale; } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } }