Skip to content

Commit

Permalink
Index: copy over indexText to Pages.bodyText to enable search result …
Browse files Browse the repository at this point in the history
…highlight
  • Loading branch information
simonwoerpel committed May 18, 2024
1 parent 10e396c commit b3a413d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions aleph/index/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ def format_proxy(proxy, collection):
log.warning("Tried to index an abstract-typed entity: %r", proxy)
return None

# FIXME
# a hack to display text previews in search for `Pages` `bodyText` property
# will be removed again in `views.serializers.EntitySerializer` to reduce
# api response size
if proxy.schema.name == "Pages":
proxy.add("bodyText", " ".join(proxy.get("indexText")))
data = proxy.to_full_dict(matchable=True)
data["schemata"] = list(proxy.schema.names)
data["caption"] = proxy.caption
Expand Down
7 changes: 7 additions & 0 deletions aleph/views/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ def collect(self, obj):

def _serialize(self, obj):
proxy = model.get_proxy(dict(obj))
# FIXME
# a hack to display text previews in search for `Pages` `bodyText` property
# will be removed again in `views.serializers.EntitySerializer` to reduce
# api response size
if proxy.schema.name == "Pages":
proxy.pop("bodyText")

properties = {}
for prop, value in proxy.itervalues():
properties.setdefault(prop.name, [])
Expand Down

0 comments on commit b3a413d

Please sign in to comment.