[hibernate-dev] Hibernate Search Projection

Max Rydahl Andersen max.andersen at redhat.com
Fri May 18 01:41:54 EDT 2007


> Projection
> The ability to project some fields the index only avoiding the
> database roundtrip.
> fullTextQuery.setProjection("id", "summary", "author.name").list();
> will return a List<Object[]> like the regular HQL projection
> the fieldbridge has to be two way (all built-in are) and the
> projected fields have to be Store.YES or Store.COMPRESS

What about .setCachedProjection  or .setIndexedProjection to clearly signal
it is not a "real" projection ?

> It's useful when you want to display a small subset of the data,
> don't want managed objects, are OK to have a bigger index and if the
> performance of the non projection strategy doesn't meet your
> requirements (arguably uncommon);

> A few questions:
> Currently fields Store.NO or where the fieldbridge is one way are
> ignored and return null.
> The idea behind that is to be able to project across multiple
> entities / index. Not sure if it's a useful feature.

Shouldn't this result in an error ?! if the property is not actually  
"mapped"
shouldn't it fail ?

> Custom query to load objects
> You can define the Criteria query that will be use to load the
> matching objects of a lucene query.
> This is especially useful when an object graph (rather than an
> object) is expected: you can refine the fetchMode.
>
> result = s.createFullTextQuery( query ).setCriteriaQuery(
> 				s.createCriteria( Book.class ).setFetchMode( "authors",
> FetchMode.JOIN )
>                 ).list();
>
> will load the matching books and the associated authors.

What happens if the query and the criteria are totally unrelated ? And how  
are the link
done between "query" and the Criteria ? you just add an in clause on the  
"id" property "blindly" ?

> Expose resultSize()
> ie the total number of result regardless of the pagination
> fullTextQuery.setMaxResult(20)resultSize() == 3000
> A better name is more than welcome.

getResultSize() ? :)

> Feedback on those features are welcome esp projection, custom query
> and their APIs

looks cool.

-- 
--
Max Rydahl Andersen
callto://max.rydahl.andersen

Hibernate
max at hibernate.org
http://hibernate.org

JBoss a division of Red Hat
max.andersen at jboss.com




More information about the hibernate-dev mailing list