Hi,
I'm trying to use facets on a field that allows nulls. I'm using indexNullAs as below and I was expecting that facets will give results also for this value, but my query returns 3 results (two entites which have values and one which has null) and facets return count equal 2 instead of 3.
Code:
@Fields({ @Field(name = "district"),
@Field(name = "district_facet_field", analyze = Analyze.NO, indexNullAs = Field.DEFAULT_NULL_TOKEN) })
@Facet(name = "district_facet_field", forField = "district_facet_field", encoding = FacetEncodingType.STRING)
@Column(name = "a_district")
private String district;
I did debug it and get to a conclusion that it may be related to the code that is executed when indexing entites, because in
Code:
class DocumentBuilderIndexedEntity {
...
private void buildDocumentFieldsForProperties(Document document,
FacetHandling faceting,
TypeMetadata typeMetadata,
ConversionContext conversionContext,
InstanceInitializer objectInitializer,
float documentBoost,
Object unproxiedInstance,
boolean multiValued){
...
addFacetDocValues( document, fieldMetadata, facetMetadata, currentFieldValue );
}
private void addFacetDocValues(Document document,
DocumentFieldMetadata fieldMetadata,
FacetMetadata facetMetadata,
Object value) {
// we don't add null values to the facet field
if ( value == null ) {
return;
}
....
}
}
currentFieldValue passed to addFacetDocValues has the actual value, so null in my case, and not the indexAsNull value, which I would expect.
Can someone explain to me if it is really inconsistent with the indexNullAs for field or my expectations are wrong and I just have to deal with the fact that facets can't be done on null values even when indexNullAs is used?
Best regards,
Pawel