Hi all,

I have a node type that has an integer CCK field with holds values from 0 to 10.

I have managed to add the CCK field as a facet and it works fine apart from the fact that only options with values > 0 are displayed under the facet in the Faceted search block.

So if I have 5 nodes with the field set to 7, 2 nodes with it set to 4 and 30 with it set to 0 I will get the following displayed in the faceted search block...

The Field

  • 7 (5)
  • 4 (2)

No option for 0 is displayed when I would have expected...

The Field

  • 7 (5)
  • 4 (2)
  • 0 (30)

If I enter a search query manually as below then I do get all the nodes with the value 0 returned so I think the data is being stored ok its just the faceted search block seems wrong.

http://xxx.xxx.xxx.xxx/search/luceneapi_node/help?thefield[0]=0

Any ideas? Where/how should I look to try to debug this?

Many thanks

Andy

Comments

arcaic’s picture

Solved this...

The function that gets the counts for the facets does a boolean test of the value returned from the document (presumably to establish whether a value was returned). Problem is that if your documents field has a value that equates to false ie [string] "0" then it doesnt get included in the counts.

I changed the test to see if the value was NULL and it works for me. Not tested any other cases.

In luceneapi_facet.block.inc

Change...

    foreach ($items as $name => $item) {
      try {
        if (NULL !== $item['field']) {
          $value = $document->getFieldValue($item['field']);
        }
        else {
          continue;
        }
      }
      catch (Exception $e) {
        continue;
      }
      if ($value) {

        // Normalizes values to an array.  Items that have multiple values in a

To...

    foreach ($items as $name => $item) {
      try {
        if (NULL !== $item['field']) {
          $value = $document->getFieldValue($item['field']);
        }
        else {
          continue;
        }
      }
      catch (Exception $e) {
        continue;
      }
      if ($value !== NULL) {

        // Normalizes values to an array.  Items that have multiple values in a

Cheers

Andy

tdombos’s picture

Can you guide me on how to add CCK fields as facets? For me, the CCK fields do not turn up at admin/settings/luceneapi_node/facets.

cpliakas’s picture

Status: Active » Closed (works as designed)

Unfortunately this is how the 2.x version of the module works by design. 3.x will handle this better, but unless someone wants to dig in and start patching it won;t get backported to 2.x since it is an architectural change.