[infinispan-dev] new Infinispan Query API - ISPN-194
Emmanuel Bernard
emmanuel at hibernate.org
Mon Apr 4 12:53:09 EDT 2011
Nice job :)
- getBasicQuery methods are deprecated. That's from the previous design right? Was it a tech preview or was it named as full fledged API?
In the former case I'd get rid of them.
- buildQueryBuilderForClass is that really needed?
qf.buildQueryBuilderForClass( Car.class ).get();
The alternative is
qf.getSearchFactory().buildQueryBuilder(Car.class).get();
- I'm not a big fan of the constructor approach to get QueryFactory for various reasons (including the fact that it forces a concrete type and no interfaces) but it seems to be an ISPN-wide design decision
That's definitely something that could be improved in a Seam Infinispan module.
- I'd rename QueryFactory to something else as conceptually it's more an entry point to anything related to Hibernate Search, potentially indexing, stats etc: maybe SearchManager, SearchProvider, GridSearcher, TheGridReaper?
- is there an easy metaconfig to ask ISPN to store the HSearch indexes in ISPN :)
- you can't do cross Cache queries today. Is that expected? for me CacheManager.getGridSearcher almost makes sense.
- for the discovery issue, option 2 and 3 are the only two viable to me
On 4 avr. 2011, at 18:23, Sanne Grinovero wrote:
> Infinispan 4.0 contained an integration with Hibernate Search to index
> stored POJOs using the well-known Hibernate Search annotations; but
> the configuration was tricky and the API quite limited.
> With the latest changes in H.Search, we could now make a better integration.
>
> Quick recap on configuration/usage on Infinispan 4:
> 1) indexing must be enabled in Infinispan configuration
> 2) a queryHelper class must be started and pointed to known types to
> be indexed, passing it HS configuration properties
> - this would start a Hibernate Search engine
> - modifications done on the grid before the queryHelper was started
> are ignored by the indexing engine
> - list of "known entities" could not be changed
> 3) use a queryFactory to create queries, which needs to be hooked up
> the previously started queryHelper
> - the query options where a bit limited
>
> What's coming in Infinispan 5:
> 1) indexing is still be enabled in Infinispan configuration
> - Hibernate Search configuration properties are embedded in the
> Infinispan configuration
>
> <infinispan>
> <default>
> <indexing enabled="true" indexLocalOnly="true">
> <properties>
> <property
> name="hibernate.search.default.directory_provider" value="ram" />
> </properties>
> </indexing>
> </default>
> </infinispan>
>
>
> 2) no queryHelper is needed
> - lifecycle of the indexing engine is managed by Infinispan
> - new entity types are autodiscovered
> (each time a previously unseen class is put/removed it's annotation
> scanned and HS is potentially reconfigured)
>
> 3) you still use a QueryFactory, like in the examples linked below
> - exposes all features of Hibernate Search query builder DSL
> - Faceting
> - projections, etc..
>
> API, most significant classes:
> https://github.com/Sanne/infinispan/blob/eafe084a2ffa7e539768c838334ad42da3e8e565/query/src/main/java/org/infinispan/query/CacheQuery.java
> https://github.com/Sanne/infinispan/blob/eafe084a2ffa7e539768c838334ad42da3e8e565/query/src/main/java/org/infinispan/query/QueryFactory.java
>
> Two usage examples:
> https://github.com/Sanne/infinispan/blob/eafe084a2ffa7e539768c838334ad42da3e8e565/query/src/test/java/org/infinispan/query/queries/faceting/SimpleFacetingTest.java
> https://github.com/Sanne/infinispan/blob/eafe084a2ffa7e539768c838334ad42da3e8e565/query/src/test/java/org/infinispan/query/indexedembedded/CollectionsIndexingTest.java
>
> there's one catch:
> when searching for a class type, it will only include results from
> known subtypes. The targeted type is automatically added to the known
> classes, but eventually existing subtypes are not discovered.
>
> Bringing this issue to an extreme, if the query is not targeting any
> type, and no indexed types where added to the grid (even if some exist
> already as they might have been inserted by other JVMs or previous
> runs), all queries will return no results.
> How to solve this?
> - class scanning?
> - explicitly list indexed entities in Infinispan configuration?
> - a metadata cache maintaining a distributed&stored copy of known types
> - search for types in the index :) would be nice, but the current
> design in Search mandates to know the entities first to know how the
> indexes are named. without name I can't open the index, but maybe we
> could have the user specify the index names instead of all entity
> classtypes.
>
> Feedback on the API is more urgent than to solve this, so it could
> make it for Infinispan 5 Beta1.
>
> Cheers,
> Sanne
More information about the infinispan-dev
mailing list