I am looking for advice on the best way to implement meta tag filtering on our site. Our site contains a large amount of disparate types of data and we think it would be beneficial to offer this feature to our users.

I've searched high and low for this feature and I find nothing viable except the now-discontinued https://drupal.org/project/gsa_faceted_search (which wouldn't work anyway since we are on Drupal 7) The idea is to implement this directly in the google_appliance module and provide it back to the community at large.

I'm still learning about how the XML and the GSA search queries operate, so currently I am working under the assumption that the facets/filters are part of the XML returned by the GSA and need to be displayed in the template and that a search query needs to be created/sent to the GSA when a facet is selected or deselected.

If any of you have direction on how/where we should place or modify our code, that would be most helpful. If no suggestions are made, then we'll figure it out as best we can.

Thank you!
--Joel

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

iamEAP’s picture

Hey Joel,

Faceting is something I'd definitely love to support natively in this module (or if not, natively as a sub module). I think the only way this is possible with GSA is via meta tag filtering. Awhile back I wrote an article the went into detail about this among many other things. You can read up about meta tag filtering specifically, here.

You'd probably have to add meta tags in the head of all pages you wanted to be facet searchable. (e.g. <meta name="gsa_facet-content_type" value="page" />) Then, based on the tags you programmatically injected in the document head, create some kind of an interface on the search form (perhaps as a block) that lists all facets and their corresponding values, and auto-submits search queries (based on the query on the existing page) with the metatag filtering automatically appended to the query (as described in the article I linked to).

At the top of my hit list would be default faceting based on:

  • Entity type (e.g. nodes vs. taxonomies vs. users)
  • Entity bundle (e.g. "page" content type for nodes)
  • Entity creator (e.g. node author)

Though it would also be nice to be able to define completely custom facets like "by subdomain" or something less well-defined like "site section." (In the latter, the user would probably end up being responsible for adding the meta tags to document bodies...)

Hope that gets you started.

circuscowboy’s picture

I am also looking into this but in a different way. Our GSA has been set up to filter on metatags (using Dublin Core and the metatags module) so in the xml that is returned they are available as PARM object. I am going to work on a patch / or submodule that will read this PARM information and display it, probably in a block. I don't feel this module needs to create any metatags - there already is a module for that.

Here is what it looks like with facets directly with our GSA:
http://google.gov.nt.ca/search?btnG=Search&client=test_frontend&output=x...

and here is a snippet of the xml that is returned with the query:

            [PARM] => SimpleXMLElement Object
                (
                    [PC] => 0
                    [PMT] => Array
                        (
                            [0] => SimpleXMLElement Object
                                (
                                    [@attributes] => Array
                                        (
                                            [NM] => dc.subject
                                            [DN] => Topic
                                            [IR] => 0
                                            [T] => 0
                                        )

                                    [PV] => Array
                                        (
                                            [0] => SimpleXMLElement Object
                                                (
                                                    [@attributes] => Array
                                                        (
                                                            [V] => Government
                                                            [L] => 
                                                            [H] => 
                                                            [C] => 29
                                                        )

                                                )

                                            [1] => SimpleXMLElement Object
                                                (
                                                    [@attributes] => Array
                                                        (
                                                            [V] => Tax and benefits
                                                            [L] => 
                                                            [H] => 
                                                            [C] => 14
                                                        )

                                                )

                                        )

                                )
circuscowboy’s picture

Hello Eric,
So I am working on creating a block for facets and I would like to get advice on direction.
I have add a patch that puts the GSA facet information into the results array.

I could easily add this to the google_appliance_results theme and create a div with the filters.

I am liking the idea of having a block with this information. I am thinking that in order to do this the module needs to be adapted a bit. I was thinking a good direction would be to cache the results data so that it could be accessed by the block and the the results template and any other future expansion.

I am going to be working towards this over the next couple of days. Any input from you, Eric would be greatly appreciated so that my time helps the project as much as possible.

iamEAP’s picture

Hi Scott,

Hopefully, you should already be able to do just that. I submitted a patch quite awhile ago (before I was maintainer) so that search results were available outside the context of the result content itself. I needed it for onebox integration, but it should suit you for your filter block.

You can get at a statically cached copy of the result XML by calling

$results = drupal_static('google_appliance_parse_device_response_xml');

See here

circuscowboy’s picture

Thank you Eric

I was unaware of the power of that &drupal_static(__function__) line.

I have since read up on things and understand another layer of drupal caching.

For others this article is a good summary.

http://www.lullabot.com/blog/article/beginners-guide-caching-data-drupal-7

Scott

iamEAP’s picture

Category: Feature request » Support request
Status: Active » Closed (won't fix)

Re-categorizing this issue as a support request and closing out the issue after 2 years of inactivity.

My current recommendation for search faceting with GSA on Drupal is to use the Google Search Collections module to achieve essentially the same experience.