Search code examples
solrfacet

How to use json.nl arrmap with facet.missing=true


Whenever I use the json.nl=arrmap parameter with the facet.missing=true, I get the error below:

"message": "java.lang.Integer cannot be cast to java.util.Map",
    "messages": [
        "java.lang.Integer cannot be cast to java.util.Map"
    ]

Can both be used together? I don't want to use another json.nl option.


Solution

  • Using facet.missing=true with json.nl=arrmap (with json.nl=map as well) is problematic because the missing facets precisely don't have any key (facet value is missing) so their count isn't mapped as the "regular" facets, ie. :

    [{"facet_value_1": <count_1>}, {"facet_value_2": <count_2>}, <count_missing>]
    

    When the error says java.lang.Integer cannot be cast to java.util.Map, it means count_missing is a scalar value while it expects a (key, value) pair.

    You can use json.nl=arrntv instead, which is more verbose but should prevent this issue.