0

A Lucene Query is generated as so:

Query luceneQuery = builder.all().createQuery();

Then facets are applied.

I'm not sure if when facets are applied the luceneQuery is ANDed and ORed with other Querys resulting in a new Lucene Query. Alternatively, perhaps a bunch of BitSets's are applied to the original Query to refine the results. (I don't know).

If a new query is generated I'd like to retrieve it. If not, I need a rethink. That's the crux of the question.

Why:

I'm applying a faceted search on a field with multiple possible values.

E.g. TMovie.class many-to-many TTag.class (multiple-value-facet)

I'm filtering on TMovie where TTag is some value.

Anyway, the filtering works but there is a known problem whereby the Facet-counts returned are incorrect. Detailed here: Add faceting over multivalued to application using Hibernate Search and https://forum.hibernate.org/viewtopic.php?f=9&t=1010472

I'm using this solution: http://sujitpal.blogspot.ie/2007/04/lucene-search-within-search-with.html (see comment on new API under article)

The BitSet solution (in this example at least) generates counts based on the original Lucene Query. This works perfectly. However.....

If alternate (different, not TTags) facets are applied to the original query some complications arise. The Bitset solution calculates on the original Lucene query. It does not calculate on the lucene query now reduced by the application of alternate Facets (a different FacetSelection) (or even TTag Facets themselves for that matter). I.e. the count calculations are irrespective of any other FacetSelection Facets applied.

So...

A. can I get the new Lucene query after facets are applied? The BitSet solution applied to this would be correct.

B. Any other alternative suggestions?

Thanks so much.. All comments welcome.

John

4

1 回答 1

0

关于您的第一个问题,应用构面不会修改原始查询,它使用称为FacetCollector的自定义收集器- 请参阅https://github.com/hibernate/hibernate-search/blob/master/engine/src/main/java/ org/hibernate/search/query/collector/impl/FacetCollector.java。在引擎盖下,收集器使用 Lucene FieldCache进行构面计数。多值刻面也有限制的根源。FieldCache不支持每个字段有多个值。

无论如何,在分面期间不会应用其他查询,并且原始查询未修改。好处当然是性能。您指向的解决方案可能也有效,但依赖于运行多个查询。但是,它可能是您的用例的有效解决方法。

于 2013-10-18T11:31:55.050 回答