How to index attributes from associations?
When I'm indexing objects in my application (using hibernate search and lucene) I would like to store in the index some of the attributes of the object's associations. I need to store them in开发者_StackOverflow社区 the index because I need a fast retrieval of those attributes. What is the best approach for doing this?
- Store the object relationships in lucene. This seems like the easiest and fastest approach.
- Store the object relationships in db
- Store the object relationships in something separate like a fast key-value store
Any other ideas on how I can store a set of attributes from a subset of objects from my app's object graph? Which solution should I use?
If you're going to need the attributes frequently when a document is retrieved, I would stick them in the index. If their use will be infrequent, I would use option 2 or 3. If you know when you need them and when you don't, you can use a FieldSelector to control whether (or which) attributes get loaded.
Another factor to consider is the cardinality of the attributes and whether you might consider incorporating their values into queries or ranking algorithms. If the answer is yes, then you're much better off sticking them into the Lucene index.
精彩评论