This content has been marked as final.
Show 1 reply
-
1. Re: Is Infinispan a suitable alternative to EAV?
lukens Mar 5, 2014 11:46 AM (in response to lukens)OK, I managed to get somewhere with this, as I found a way to index the properties of the map.
My solution was to make use of a Class Bridge to map the properties in the maps to indexed fields, and to build up a SearchMapping programatically as follows:
SearchMapping mapping = new SearchMapping(); IndexedMapping entity = mapping.entity(Entity.class).indexed(); for (String property : properties) { entity.classBridge(EntityPropertyClassBridge.class) .name(property) .param("property", property); }
Where EntityPropertyClassBridge has the following set method:
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) { final Field field = new Field( name, objectToString(((Entity) value).properties.get(property)), luceneOptions.getStore(), luceneOptions.getIndex(), luceneOptions.getTermVector()); field.setBoost(luceneOptions.getBoost()); document.add(field); }
This seems to do the trick, and I can now search on the properties of the map. I found a couple of issues so far, though:
- If we need to add a new type of property, then we need to build a new mapping. The only way I have found to do this, and have it be applied, is to shutdown the CacheManger and start a new one with the new mapping applied for indexing the given cache. This seems less than ideal, and I'm also unsure what the overheads might be.
- I seem to be able to use a hibernate QueryBuilder (searchManager.buildQueryBuilderForClass(Entity.class).get()) to build queries without an issue, but if I try and use an Infinispan QueryFactory (searchManager..getQueryFactory()) to build the queries, then it cannot find the fields defined using classBridge().
I'm also still not sure if trying to do this is A Good Idea™.