I'm sorry I missed those other questions.
You're right, this is how it works and the use case you describe requires some care. There are many different ways to do it, but mainly they can be classified in the following general approaches:
# Encode them together With a custom FieldBridge or ClassBridge you make sure you encode the two properties which need not be separated as a single keyword. For example you could store it index it as "testb1|true". That's not convenient at all for free-form full text but it works well for flags, codes and other metadata which is not related with full-text.
# Reverse the relationship Don't target entity A, but search for all types B. Of course this only works in simple cases, were you don't have multiple _toMany relations. The case of your example it would work fine, but it's not a silver bullet.
# Combine the full-text query with a Criteria In this section of the documentation we mention that you can customize the Criteria used to load results: - http://docs.jboss.org/hibernate/search/5.5/reference/en-US/html_single/#_building_a_hibernate_search_query We also explain that you really shouldn't use that to apply further restrictions via SQL, as this hasn't been tested much and it will throw-off some statistics like the expected amount of results. But as a matter of fact, it's working for some people.. Just make sure you understand you're cheating a bit and test it carefully.
# Post-processing If you're not loading many thousands of objects this way, you might want to simply filter out some results in your own code.
# Don't ;-) When it comes down to complex relational queries, it's probably better to use the relational database for this.
I should add that we're exploring possible improvements on the area, but it will always be a complex matter. For example we might be able to do a single join, but not more than one.
_________________ Sanne http://in.relation.to/
|