Skip to content

Commit b3a413d

Browse files
committed
Index: copy over indexText to Pages.bodyText to enable search result highlight
1 parent 10e396c commit b3a413d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

aleph/index/entities.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ def format_proxy(proxy, collection):
185185
log.warning("Tried to index an abstract-typed entity: %r", proxy)
186186
return None
187187

188+
# FIXME
189+
# a hack to display text previews in search for `Pages` `bodyText` property
190+
# will be removed again in `views.serializers.EntitySerializer` to reduce
191+
# api response size
192+
if proxy.schema.name == "Pages":
193+
proxy.add("bodyText", " ".join(proxy.get("indexText")))
188194
data = proxy.to_full_dict(matchable=True)
189195
data["schemata"] = list(proxy.schema.names)
190196
data["caption"] = proxy.caption

aleph/views/serializers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@ def collect(self, obj):
200200

201201
def _serialize(self, obj):
202202
proxy = model.get_proxy(dict(obj))
203+
# FIXME
204+
# a hack to display text previews in search for `Pages` `bodyText` property
205+
# will be removed again in `views.serializers.EntitySerializer` to reduce
206+
# api response size
207+
if proxy.schema.name == "Pages":
208+
proxy.pop("bodyText")
209+
203210
properties = {}
204211
for prop, value in proxy.itervalues():
205212
properties.setdefault(prop.name, [])

0 commit comments

Comments
 (0)