views:

76

answers:

1

I'm currently trying to use NHibernate.Search, but i need to get score for each results returned by the query.

Anyone know something about how to do that ?

Thanks.

A: 

If you are using projections you can do this by having one of the properties that you are projecting to be a ProjectionConstants.SCORE reference. This will cause lucene to return values stored in the index than making a query to the database. The query will return an arraylist of object[] values instead of objects.

for example.

IFullTextQuery query = search.CreateFullTextQuery("query goes here");

query.SetProjection("FirstName", "LastName", ProjectionConstants.SCORE);
Andrew Smith
Thanks Andrew, but actually i retrive my objects with NHibernate.Search with the List<T>() method, so can i still use List<T> with projections ?
Yoann. B
There is no other way to automatically obtain a score using NHibernate.Search without using projections.
Andrew Smith