UNOMI-16 : added elasticsearch mappings
Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/815ab750 Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/815ab750 Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/815ab750 Branch: refs/heads/master Commit: 815ab75000d54655db0193f83f100c757ee4e046 Parents: c9f2471 Author: Thomas Draier <[email protected]> Authored: Wed Feb 3 18:34:34 2016 +0100 Committer: Thomas Draier <[email protected]> Committed: Fri Feb 5 11:32:20 2016 +0100 ---------------------------------------------------------------------- .../ElasticSearchPersistenceServiceImpl.java | 8 +- .../META-INF/cxs/mappings/campaign.json | 71 ++++++++++- .../META-INF/cxs/mappings/campaignevent.json | 63 +++++++++- .../resources/META-INF/cxs/mappings/event.json | 62 +++++++--- .../resources/META-INF/cxs/mappings/goal.json | 76 ++++++++++-- .../META-INF/cxs/mappings/persona.json | 28 ++--- .../META-INF/cxs/mappings/personaSession.json | 52 ++++---- .../META-INF/cxs/mappings/profile.json | 52 +++++--- .../META-INF/cxs/mappings/propertyType.json | 123 +++++++++++++++++-- .../resources/META-INF/cxs/mappings/rule.json | 79 +++++++++--- .../META-INF/cxs/mappings/segment.json | 70 ++++++++--- .../META-INF/cxs/mappings/session.json | 79 ++++++++---- 12 files changed, 602 insertions(+), 161 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/815ab750/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java ---------------------------------------------------------------------- diff --git a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java index 8d6c5fb..042f5c1 100644 --- a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java +++ b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java @@ -342,7 +342,7 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService, @Override public void bundleChanged(BundleEvent event) { switch (event.getType()) { - case BundleEvent.STARTED: + case BundleEvent.STARTING: if (event.getBundle() != null && event.getBundle().getRegisteredServices() != null) { for (ServiceReference<?> reference : event.getBundle().getRegisteredServices()) { Object service = bundleContext.getService(reference); @@ -414,13 +414,15 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService, if (itemsMonthlyIndexed.contains(name)) { createMapping(name, content.toString(), indexName + "-*"); } else if (indexNames.containsKey(name)) { - createMapping(name, content.toString(), indexNames.get(name)); + if (client.admin().indices().prepareExists(indexNames.get(name)).execute().actionGet().isExists()) { + createMapping(name, content.toString(), indexNames.get(name)); + } } else { createMapping(name, content.toString(), indexName); } } } catch (Exception e) { - logger.error("Error while loading segment definition " + predefinedMappingURL, e); + logger.error("Error while loading mapping definition " + predefinedMappingURL, e); } } } http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/815ab750/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/campaign.json ---------------------------------------------------------------------- diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/campaign.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/campaign.json index 2ddac89..c469be8 100644 --- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/campaign.json +++ b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/campaign.json @@ -11,6 +11,75 @@ } } } - ] + ], + "properties": { + "cost": { + "type": "double" + }, + "currency": { + "type": "string", + "analyzer": "folding" + }, + "startDate": { + "type": "date", + "format": "dateOptionalTime" + }, + "endDate": { + "type": "date", + "format": "dateOptionalTime" + }, + "itemId": { + "type": "string", + "analyzer": "folding" + }, + "itemType": { + "type": "string", + "analyzer": "folding" + }, + "primaryGoal": { + "type": "string", + "analyzer": "folding" + }, + "timezone": { + "type": "string", + "analyzer": "folding" + }, + "metadata": { + "properties": { + "description": { + "type": "string", + "analyzer": "folding" + }, + "enabled": { + "type": "boolean" + }, + "hidden": { + "type": "boolean" + }, + "id": { + "type": "string", + "analyzer": "folding" + }, + "missingPlugins": { + "type": "boolean" + }, + "name": { + "type": "string", + "analyzer": "folding" + }, + "readOnly": { + "type": "boolean" + }, + "scope": { + "type": "string", + "analyzer": "folding" + }, + "tags": { + "type": "string", + "analyzer": "folding" + } + } + } + } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/815ab750/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/campaignevent.json ---------------------------------------------------------------------- diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/campaignevent.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/campaignevent.json index 3c24541..e9ce4d3 100644 --- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/campaignevent.json +++ b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/campaignevent.json @@ -11,6 +11,67 @@ } } } - ] + ], + "properties": { + "campaignId": { + "type": "string", + "analyzer": "folding" + }, + "cost": { + "type": "double" + }, + "currency": { + "type": "string", + "analyzer": "folding" + }, + "eventDate": { + "type": "date", + "format": "dateOptionalTime" + }, + "itemId": { + "type": "string", + "analyzer": "folding" + }, + "itemType": { + "type": "string", + "analyzer": "folding" + }, + "timezone": { + "type": "string", + "analyzer": "folding" + }, + "metadata": { + "properties": { + "description": { + "type": "string", + "analyzer": "folding" + }, + "enabled": { + "type": "boolean" + }, + "hidden": { + "type": "boolean" + }, + "id": { + "type": "string", + "analyzer": "folding" + }, + "missingPlugins": { + "type": "boolean" + }, + "name": { + "type": "string", + "analyzer": "folding" + }, + "readOnly": { + "type": "boolean" + }, + "scope": { + "type": "string", + "analyzer": "folding" + } + } + } + } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/815ab750/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/event.json ---------------------------------------------------------------------- diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/event.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/event.json index 73af986..abe1dbc 100644 --- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/event.json +++ b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/event.json @@ -1,21 +1,47 @@ { - "event": { - "dynamic_templates": [ - { - "all": { - "match": "*", - "match_mapping_type": "string", - "mapping": { - "type": "string", - "analyzer": "folding" - } - } - } - ], - "properties": { - "timeStamp": { - "type": "date" - } + "event": { + "dynamic_templates": [ + { + "all": { + "match": "*", + "match_mapping_type": "string", + "mapping": { + "type": "string", + "analyzer": "folding" + } } + } + ], + "properties": { + "eventType": { + "type": "string", + "analyzer": "folding" + }, + "itemId": { + "type": "string", + "analyzer": "folding" + }, + "itemType": { + "type": "string", + "analyzer": "folding" + }, + "profileId": { + "type": "string", + "analyzer": "folding" + }, + "scope": { + "type": "string", + "analyzer": "folding" + }, + "sessionId": { + "type": "string", + "analyzer": "folding" + }, + "timeStamp": { + "type": "date", + "format": "dateOptionalTime" + } } -} \ No newline at end of file + } +} + http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/815ab750/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/goal.json ---------------------------------------------------------------------- diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/goal.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/goal.json index d8bd37e..0fb7bcf 100644 --- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/goal.json +++ b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/goal.json @@ -1,16 +1,66 @@ { - "goal": { - "dynamic_templates": [ - { - "all": { - "match": "*", - "match_mapping_type": "string", - "mapping": { - "type": "string", - "analyzer": "folding" - } - } - } - ] + "goal": { + "dynamic_templates": [ + { + "all": { + "match": "*", + "match_mapping_type": "string", + "mapping": { + "type": "string", + "analyzer": "folding" + } + } + } + ], + "properties": { + "campaignId": { + "type": "string", + "analyzer": "folding" + }, + "itemId": { + "type": "string", + "analyzer": "folding" + }, + "itemType": { + "type": "string", + "analyzer": "folding" + }, + "metadata": { + "properties": { + "description": { + "type": "string", + "analyzer": "folding" + }, + "enabled": { + "type": "boolean" + }, + "hidden": { + "type": "boolean" + }, + "id": { + "type": "string", + "analyzer": "folding" + }, + "missingPlugins": { + "type": "boolean" + }, + "name": { + "type": "string", + "analyzer": "folding" + }, + "readOnly": { + "type": "boolean" + }, + "scope": { + "type": "string", + "analyzer": "folding" + }, + "tags": { + "type": "string", + "analyzer": "folding" + } + } + } } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/815ab750/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/persona.json ---------------------------------------------------------------------- diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/persona.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/persona.json index 8c6ef0d..d04715f 100644 --- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/persona.json +++ b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/persona.json @@ -1,16 +1,16 @@ { - "persona": { - "dynamic_templates": [ - { - "all": { - "match": "*", - "match_mapping_type": "string", - "mapping": { - "type": "string", - "analyzer": "folding" - } - } - } - ] - } + "persona": { + "dynamic_templates": [ + { + "all": { + "match": "*", + "match_mapping_type": "string", + "mapping": { + "type": "string", + "analyzer": "folding" + } + } + } + ] + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/815ab750/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/personaSession.json ---------------------------------------------------------------------- diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/personaSession.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/personaSession.json index 7c8e0f5..6ba12aa 100644 --- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/personaSession.json +++ b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/personaSession.json @@ -1,31 +1,31 @@ { - "personaSession": { - "dynamic_templates": [ - { - "all": { - "match": "*", - "match_mapping_type": "string", - "mapping": { - "type": "string", - "analyzer": "folding" - } - } - } - ], + "personaSession": { + "dynamic_templates": [ + { + "all": { + "match": "*", + "match_mapping_type": "string", + "mapping": { + "type": "string", + "analyzer": "folding" + } + } + } + ], + "properties": { + "timeStamp": { + "type": "date" + }, + "lastEventDate": { + "type": "date" + }, + "properties": { "properties": { - "timeStamp": { - "type": "date" - }, - "lastEventDate": { - "type": "date" - }, - "properties": { - "properties": { - "location": { - "type": "geo_point" - } - } - } + "location": { + "type": "geo_point" + } } + } } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/815ab750/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/profile.json ---------------------------------------------------------------------- diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/profile.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/profile.json index b6dcce0..bfd6939 100644 --- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/profile.json +++ b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/profile.json @@ -1,18 +1,40 @@ { - "profile": { - "_all" : {"enabled" : true}, - "dynamic_templates": [ - { - "all": { - "match": "*", - "match_mapping_type": "string", - "mapping": { - "type": "string", - "analyzer": "folding", - "include_in_all" : true - } - } - } - ] + "profile": { + "_all": { + "enabled": true + }, + "dynamic_templates": [ + { + "all": { + "match": "*", + "match_mapping_type": "string", + "mapping": { + "type": "string", + "analyzer": "folding", + "include_in_all": true + } + } + } + ], + "properties": { + "itemId": { + "type": "string", + "analyzer": "folding", + "include_in_all": true + }, + "itemType": { + "type": "string", + "analyzer": "folding", + "include_in_all": true + }, + "properties": { + "properties": { + "firstVisit": { + "type": "date", + "format": "dateOptionalTime" + } + } + } } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/815ab750/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/propertyType.json ---------------------------------------------------------------------- diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/propertyType.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/propertyType.json index 204cbea..88a958e 100644 --- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/propertyType.json +++ b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/propertyType.json @@ -1,16 +1,113 @@ { - "propertyType": { - "dynamic_templates": [ - { - "all": { - "match": "*", - "match_mapping_type": "string", - "mapping": { - "type": "string", - "analyzer": "folding" - } - } - } - ] + "propertyType": { + "dynamic_templates": [ + { + "all": { + "match": "*", + "match_mapping_type": "string", + "mapping": { + "type": "string", + "analyzer": "folding" + } + } + } + ], + "properties": { + "automaticMappingsFrom": { + "type": "string", + "analyzer": "folding" + }, + "dateRanges": { + "properties": { + "from": { + "type": "string", + "analyzer": "folding" + }, + "key": { + "type": "string", + "analyzer": "folding" + }, + "to": { + "type": "string", + "analyzer": "folding" + } + } + }, + "defaultValue": { + "type": "string", + "analyzer": "folding" + }, + "itemId": { + "type": "string", + "analyzer": "folding" + }, + "itemType": { + "type": "string", + "analyzer": "folding" + }, + "mergeStrategy": { + "type": "string", + "analyzer": "folding" + }, + "metadata": { + "properties": { + "enabled": { + "type": "boolean" + }, + "hidden": { + "type": "boolean" + }, + "id": { + "type": "string", + "analyzer": "folding" + }, + "missingPlugins": { + "type": "boolean" + }, + "name": { + "type": "string", + "analyzer": "folding" + }, + "readOnly": { + "type": "boolean" + } + } + }, + "multivalued": { + "type": "boolean" + }, + "numericRanges": { + "properties": { + "from": { + "type": "double" + }, + "key": { + "type": "string", + "analyzer": "folding" + }, + "to": { + "type": "double" + } + } + }, + "protected": { + "type": "boolean" + }, + "rank": { + "type": "double" + }, + "tags": { + "type": "string", + "analyzer": "folding" + }, + "target": { + "type": "string", + "analyzer": "folding" + }, + "type": { + "type": "string", + "analyzer": "folding" + } } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/815ab750/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/rule.json ---------------------------------------------------------------------- diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/rule.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/rule.json index eb4b599..67263cf 100644 --- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/rule.json +++ b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/rule.json @@ -1,22 +1,67 @@ { - "rule": { - "dynamic_templates": [ - { - "all": { - "match": "*", - "match_mapping_type": "string", - "mapping": { - "type": "string", - "analyzer": "folding" - } - } - } - ], + "rule": { + "dynamic_templates": [ + { + "all": { + "match": "*", + "match_mapping_type": "string", + "mapping": { + "type": "string", + "analyzer": "folding" + } + } + } + ], + "properties": { + "itemId": { + "type": "string", + "analyzer": "folding" + }, + "itemType": { + "type": "string", + "analyzer": "folding" + }, + "metadata": { "properties": { - "priority": { - "type": "long" - } + "description": { + "type": "string", + "analyzer": "folding" + }, + "enabled": { + "type": "boolean" + }, + "hidden": { + "type": "boolean" + }, + "id": { + "type": "string", + "analyzer": "folding" + }, + "missingPlugins": { + "type": "boolean" + }, + "name": { + "type": "string", + "analyzer": "folding" + }, + "readOnly": { + "type": "boolean" + }, + "scope": { + "type": "string", + "analyzer": "folding" + } } - + }, + "priority": { + "type": "long" + }, + "raiseEventOnlyOnceForProfile": { + "type": "boolean" + }, + "raiseEventOnlyOnceForSession": { + "type": "boolean" + } } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/815ab750/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/segment.json ---------------------------------------------------------------------- diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/segment.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/segment.json index 718ad55..c4527a5 100644 --- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/segment.json +++ b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/segment.json @@ -1,16 +1,58 @@ { - "segment": { - "dynamic_templates": [ - { - "all": { - "match": "*", - "match_mapping_type": "string", - "mapping": { - "type": "string", - "analyzer": "folding" - } - } - } - ] + "segment": { + "dynamic_templates": [ + { + "all": { + "match": "*", + "match_mapping_type": "string", + "mapping": { + "type": "string", + "analyzer": "folding" + } + } + } + ], + "properties": { + "itemId": { + "type": "string", + "analyzer": "folding" + }, + "itemType": { + "type": "string", + "analyzer": "folding" + }, + "metadata": { + "properties": { + "description": { + "type": "string", + "analyzer": "folding" + }, + "enabled": { + "type": "boolean" + }, + "hidden": { + "type": "boolean" + }, + "id": { + "type": "string", + "analyzer": "folding" + }, + "missingPlugins": { + "type": "boolean" + }, + "name": { + "type": "string", + "analyzer": "folding" + }, + "readOnly": { + "type": "boolean" + }, + "scope": { + "type": "string", + "analyzer": "folding" + } + } + } } -} \ No newline at end of file + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/815ab750/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/session.json ---------------------------------------------------------------------- diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/session.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/session.json index 8f1c722..ef808ed 100644 --- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/session.json +++ b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/session.json @@ -1,31 +1,58 @@ { - "session": { - "dynamic_templates": [ - { - "all": { - "match": "*", - "match_mapping_type": "string", - "mapping": { - "type": "string", - "analyzer": "folding" - } - } - } - ], + "session": { + "dynamic_templates": [ + { + "all": { + "match": "*", + "match_mapping_type": "string", + "mapping": { + "type": "string", + "analyzer": "folding" + } + } + } + ], + "properties": { + "duration": { + "type": "long" + }, + "itemId": { + "type": "string", + "analyzer": "folding" + }, + "itemType": { + "type": "string", + "analyzer": "folding" + }, + "lastEventDate": { + "type": "date", + "format": "dateOptionalTime" + }, + "profileId": { + "type": "string", + "analyzer": "folding" + }, + "properties": { "properties": { - "timeStamp": { - "type": "date" - }, - "lastEventDate": { - "type": "date" - }, - "properties": { - "properties": { - "location": { - "type": "geo_point" - } - } - } + "location": { + "type": "geo_point" + } } + }, + "scope": { + "type": "string", + "analyzer": "folding" + }, + "size": { + "type": "long" + }, + "systemProperties": { + "type": "object" + }, + "timeStamp": { + "type": "date", + "format": "dateOptionalTime" + } } + } } \ No newline at end of file
