Hi,
I'm running into a problem which I'm not sure is configuration-related or a Hibernate Search limitation.
We have Hibernate Search working well, and are successfully faceting on a number of fields. However, our application is not correctly returning facet values for when there are multiple values for the
same facet for a document.
For the following (simplified) domain object:
Code:
@Entity
@Indexed(index = "Item")
public class PhysicalItem extends AbstractMaterialItem implements Serializable {
@Embedded
@IndexedEmbedded
@Field(name = "preservation_facet", index = Index.UN_TOKENIZED)
@FieldBridge(impl = PreservationBridge.class)
private Preservation preservation;
}
and the following bridge (again, simplified for example's sake):
Code:
public class PreservationBridge implements FieldBridge {
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
luceneOptions.addFieldToDocument(name, "test1", document);
luceneOptions.addFieldToDocument(name, "test2", document);
}
}
Ten PhysicalItems are committed. When querying the Lucene index through Hibernate search, we get the following for the facet values:
- test1 - 2 values
- test2 - 8 values
I would have expected to see 10 values for both. This almost suggests that Hibernate Search isn't correctly dealing with multiple facet values of the same type for a document. I can confirm through Luke that all ten documents match for both preservation_facet:test1 and preservation_facet:test2.
If it's of any relevance, we're building the faceting request via the following code snippet:
Code:
QueryBuilder builder = fullTextEntityManager.getSearchFactory().buildQueryBuilder().forEntity(PhysicalItem.class).get();
FacetingRequest facetingRequest = builder.facet().name("Preservation").onField("preservation_facet").discrete().includeZeroCounts(false).maxFacetCount(20).createFacetingRequest();
We're using Hibernate Search 3.4.0.Final (this is because we're using Hibernate Tools in our project which
still doesn't support Hibernate 4.x, so we're kinda stuck at the moment unless we run two versions of Hibernate in parallel).
What am I missing?
Thanks,
Matt