I am using Search API Solr search along with this module and taxonomies are just listed as a flat list, with all terms out of order. How can I get taxonomies to show in their hierarchies?

CommentFileSizeAuthor
#7 irc1.png5.71 KBmiiimooo
#7 irc2.png5.83 KBmiiimooo

Comments

cpliakas’s picture

It's important to note that Facet API integration isn't in the Search API module yet. I want to confirm that you are testing the integration via the Search API Facet API Integration code.

Thanks,
Chris

cpliakas’s picture

Status: Active » Closed (cannot reproduce)

Closing after weeks of inactivity.

a_lawry’s picture

Status: Closed (cannot reproduce) » Active

Hi Chris,

I noticed this also. Example here:

http://bigtravel.sunbear.com.au/tour-search/hiking

The countries vocabulary has a hierarchy it is divided into regions so it looks something like this:

= Europe
- Germany
- France
- Italy
= South America
- Brazil
- Peru

I was expecting it to display as a hierarchy in the facet block. I'm 99% sure it was working correctly when I was using the apache solr module with facet API. Now I've switched over to Search API and Facet API (Still with apache solr backend) I'm just getting the flat list.

What is the expected behaviour?

cpliakas’s picture

The expected behavior is to display them if a hierarchical fashion if a) you are using a version of Search API that supports hierarchical indexing of taxonomy terms and b) Facet API is configured to display that facet as hierarchical. The Facet API hierarchy processing is definitely working, the trick is making sure that your configurations are correct and that your version of Search API supports hierarchical indexing of taxonomy terms.

a_lawry’s picture

Thanks Chris. Found it here:

"Oh, and you'll need to activate the "Index hierarchy" data alteration and tell it to also index the parent terms for the field in question."

#1258740: Taxonomy hierarchy as facet

cpliakas’s picture

Status: Active » Postponed (maintainer needs more info)

Good find. So I would recommend installing the latest version of Search API, reindex your content, and seeing if that clears up the issue.

Thanks for posting back,
Chris

miiimooo’s picture

Status: Postponed (maintainer needs more info) » Active
StatusFileSize
new5.83 KB
new5.71 KB

There's a bug somewhere with hierarchies. Not sure we have exactly the same one. Have a look a the two screenshots. The term "Art 10.1 (d)" (4) keeps popping up though it's in the "Qualification Directive" hierarchy. Not sure how to reproduce this but let me know if there's anything else you want to know.

EDIT: I've dug a bit deeper into facetapi. What seems to be the problem is this:

protected function processHierarchy(array $build) {
..
    if ($this->facet['hierarchy callback']) {
      $parents = $this->facet['hierarchy callback'](array_keys($build));
      foreach ($parents as $value => $parents) {
        foreach ($parents as $parent) {
          if (isset($build[$parent]) && isset($build[$value])) {

$build contains tids. If $build doesn't contain the parent of a term then the term becomes an orphan.

So, for instance, when you have a term with depth 3 then it will move to the top level if its parent with depth 2 isn't selected.

cpliakas’s picture

OK, interesting. So which backend module are you using (Apache Solr Search Integration or Search API)?. If you are using Search API, are you indexing the parents along with the children? For example, if you have a "food" -> "fruit" -> "apple" hierarchy then selecting "apple" will also index the content as being tagged with "fruit" and "food"?

miiimooo’s picture

We're using Search API, Index hierarchy is enabled and the field is selected. Not sure where to look in SOLR to figure out what it indexes

miiimooo’s picture

This driving me a bit insane. In search_api_facetapi I get this item before indexing (and using the hierarchy alteration)

...
nid (String, 3 characters ) 177
...
field_leg_cited (Array, 10 elements)
    1 (String, 1 characters ) 1
    173 (String, 3 characters ) 173
    99 (String, 2 characters ) 99
    101 (String, 3 characters ) 101
    98 (String, 2 characters ) 98
    119 (String, 3 characters ) 119
    103 (String, 3 characters ) 103
    180 (String, 3 characters ) 180
    225 (String, 3 characters ) 225
    121 (String, 3 characters ) 121

And when I do a search that brings up item with nid 177 I get this:

search_api_facets (Array, 1 element)

    field_leg_cited (Array, 10 elements)
        0 (Array, 2 elements)
            filter (String, 5 characters ) "105"
            count (Integer) 10
        1 (Array, 2 elements)
            filter (String, 5 characters ) "178"
            count (Integer) 9
        2 (Array, 2 elements)
            filter (String, 3 characters ) "1"
            count (Integer) 8
        3 (Array, 2 elements)
            filter (String, 3 characters ) "6"
            count (Integer) 7
        4 (Array, 2 elements)
            filter (String, 3 characters ) "7"
            count (Integer) 6
        5 (Array, 2 elements)
            filter (String, 5 characters ) "180"
            count (Integer) 4
        6 (Array, 2 elements)
            filter (String, 5 characters ) "113"
            count (Integer) 3
        7 (Array, 2 elements)
            filter (String, 5 characters ) "319"
            count (Integer) 3
        8 (Array, 2 elements)
            filter (String, 5 characters ) "103"
            count (Integer) 2
        9 (Array, 2 elements)
            filter (String, 5 characters ) "106"
            count (Integer) 2

To explain - 119 which is the parent of 103 has disappeared. Maybe it's a bug in search_api (_solr)?

miiimooo’s picture

I've figured this one out. The problem lies in the facet.limit field. This limits the total number of (in my case) term ids that will be returned per facet. I had set this to 10 and since this is a big hierarchical taxonomy a result can have more than 10 tids (including parents). Changing the facet.limit to 100 in facet display / global settings / hard limit fixes the problem. It's conceivable that bigger hierarchical taxonomies will hit the 100 limit though

miiimooo’s picture

Status: Active » Fixed
cpliakas’s picture

Thanks for posting back!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

egarias’s picture

I do have this issue.
no children nodes are shown.
I checked $this->facet['hierarchy callback'] is not settled.
This is my path: http://solomoto.es/taxonomy/term/1/seccion/competici%C3%B3n-5

The term I want to show hierarchy is vocabulary->seccion term->competici%C3%B3n tid->5

maybe there's an error and the facet api considers taxonomy/term/1 as the term to check hierarchy?, the path in the $build object is allways #path=taxonomy/term/1

any help?

Thanks

egarias’s picture

Version: 7.x-1.0-beta6 » 7.x-1.0-rc4
Status: Closed (fixed) » Active

Sorry, I do reopen for help

cpliakas’s picture

Status: Active » Closed (fixed)

egarias,

You have two threads going on here. Let's keep this one fixed as there was a problem that was solved, as introducing a new topic half way through will cause confusion to others trying to read it through. Let's continue discussing at #1641886: Taxonomy parent doesn't show children nodes where you can post the answer to my question in addition to what didn't work for you in this thread.

Thanks,
Chris