-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Facets on a field with null values - addFacetDocValues
PostPosted: Sat Nov 05, 2016 11:41 am 
Newbie

Joined: Sat Nov 05, 2016 11:29 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.