Added owner ID field to index mapping
authorThierry Florac <tflorac@ulthar.net>
Sat, 18 Jul 2020 19:37:58 +0200
changeset 163 838fd9ca54fb
parent 162 41093bb671a5
child 164 e48a3850c17a
Added owner ID field to index mapping
docs/mappings/index-settings.json
src/pyams_content_es/document.py
--- a/docs/mappings/index-settings.json	Fri Jul 17 08:57:45 2020 +0200
+++ b/docs/mappings/index-settings.json	Sat Jul 18 19:37:58 2020 +0200
@@ -92,6 +92,9 @@
 				"data_type": {
 					"type": "keyword"
 				},
+				"owner_id": {
+					"type": "keyword"
+				},
 				"title": {
 					"type": "object",
 					"properties": {
--- a/src/pyams_content_es/document.py	Fri Jul 17 08:57:45 2020 +0200
+++ b/src/pyams_content_es/document.py	Sat Jul 18 19:37:58 2020 +0200
@@ -17,7 +17,7 @@
 from zope.interface import classImplements
 from zope.intid.interfaces import IIntIds
 
-from pyams_content.shared.common import WfSharedContent
+from pyams_content.shared.common import IWfSharedContentRoles, WfSharedContent
 from pyams_content.shared.common.interfaces import IWfSharedContent
 from pyams_content.shared.common.interfaces.types import IWfTypedSharedContent
 from pyams_content_es.interfaces import IDocumentIndexInfo, IDocumentIndexTarget
@@ -49,6 +49,10 @@
     def reference_id(self):
         return ISequentialIdInfo(self).hex_oid
 
+    @property
+    def owner_id(self):
+        return list(IWfSharedContentRoles(self).owner or ())
+
     def elastic_mapping(self):
         return IDocumentIndexInfo(self)
 
@@ -71,6 +75,7 @@
     return ESMapping(analyzer='content',
                      properties=ESMapping(ESField('internal_id'),
                                           ESField('reference_id'),
+                                          ESField('owner_id'),
                                           ESField('content_type'),
                                           ESField('title', boost=3.0),
                                           ESField('short_name'),
@@ -84,6 +89,7 @@
     return ESMapping(analyzer='content',
                      properties=ESMapping(ESField('internal_id'),
                                           ESField('reference_id'),
+                                          ESField('owner_id'),
                                           ESField('content_type'),
                                           ESField('data_type'),
                                           ESField('title', boost=3.0),