: incorrect. The source of the problem is in-fact submitting a document with
: a blank field value. The JSON returned by a query containing the
: problematic value, is when doing a facet search. Details below:
        ...
: "facet_fields": {
: "year": {
: "": 1
: }
: },
        ...
: As you can see above the facet count for the '*year*' field contains a
: blank JSON field name. This errors when parsing with *PHP's json_decode*
: (...).
: 
: *Fatal error*: Cannot access empty property in ............

Not sure what to tell you about that ... it's definitely valid JSON, if 
PHP's json_decode method doesn't like it, that seems like soemthing you 
may want to ask other PHP users about?

But, FWIW: I think you're still wrong about the route cause of your 
problem...

my version of PHP's json_decode doesn't seem to have any problem with that 
JSON, and doesn't produce that error.  although: it does some funky things 
with the key "" when it builds up PHP "objects" (but according to the 
docs, you can override this using the "assoc" option to json_decode) so 
maybe you're making an assumption about what the key name is and that's 
not true with the object PHP generates for you?


php > $data = '{ "facet_fields": {"categories": { "": 42, "has space": 36} } }';
php > var_dump(json_decode($data));
object(stdClass)#1 (1) {
  ["facet_fields"]=>
  object(stdClass)#2 (1) {
    ["categories"]=>
    object(stdClass)#3 (2) {
      ["_empty_"]=>
      int(42)
      ["has space"]=>
      int(36)
    }
  }
}
php > var_dump(json_decode($data, true));
array(1) {
  ["facet_fields"]=>
  array(1) {
    ["categories"]=>
    array(2) {
      [""]=>
      int(42)
      ["has space"]=>
      int(36)
    }
  }
}









-Hoss
http://www.lucidworks.com/

Reply via email to