Hi!
my problem ist probably trivial, but I couldn't find an answer anywhere in the Hibernate Search documentation: how do I force HS or Lucene to only return objects of a particular kind?
Imagine an application where I have two kinds of Entites, say User and Product, both with a field "name". Both are indexed, so when I do a query like "name:foo", I will not only find Mr. John Foo, but also the FooProduct. My result set is just a mixed bag, so if I solve this via "instanceof", my pagination and result count will be messed up.
A simple way to work around this is renaming the field "name", e.g. to "userName" and "productName". But this is not only ugly in itself but also a clever user could manage to circumvent the "default" field and query the others.
I know that restricting the kind of entities returned by a query kind of defeats the purpose of full-text indexing, but it sure makes sense in my case (and no, I don't actually index users).
Cheers, Friedrich
|