[hibernate-dev] Projecting an index

Marc Schipperheyn m.schipperheyn at gmail.com
Wed Sep 3 11:58:30 EDT 2014


I'm wondering if would be conceivable to project a custom index based on
the programmatic API when you are also using Annotations?

Our use case is basically that we have a social "wall" where we retrieve
"posts" which can reference related objects: other posts, user info,
classifieds, events, groups, etc.

In most cases, we'll reference these with a title, url, description and
photo. Additionally, each object can have a specific property, such as an
event having a startDate and an RSVP.

We don't store this information directly in the post index because changes
in them could affect a large number of posts and have undesired
 performance impacts

We are avoiding to load stuff from the database because of the load each
retrieval could generate and are basically loading as much as possible from
the index. One alternative approach would be to use the index to load post
ids and then load the posts as is from the database = large number of
queries through lazy initialization. We went the pure index way.

In order to load all this information each load of a list of posts requires
some preloading and some iterations to first load the posts and then load
related objects from their own indices. This kind of staggered approach
offers some nice caching opportunities.

But ideally, I would like to have a limited flattened index that contains
all the related data for a post, but that does allow me to automatically
update data in it if the underlying object changes.

ideally, I would like to store in that index something like this

object class
id
title
url
description
photo
[custom fields]

I'm curious if something like this would be achievable with HSearch?


More information about the hibernate-dev mailing list