hi. im using the module and it works great for some views.
however, the navigation block does not appear for a view that was created by the Search API (http://drupal.org/project/search_api)
i am using a view that uses fulltext search and facets to filter nodes (icl. apache solr integration).
--
is the module supposed to work with every view? am i probably missing smth. to get it work?
please let me know if you need further information about my setup.

thanks for your support in advance!

CommentFileSizeAuthor
#5 search_api_get_results-1999542-5.patch0 byteslunatic

Comments

gaëlg’s picture

Category: support » feature

As mentioned in the Readme file, the module currently only handles the default query plugin. I might add search API integration if I need it someday. Meanwhile, I'll review any patch on this feature request.

ada05’s picture

Status: Active » Postponed

ok. sorry i missed that or didnt quite understand "default query plugin" (-> pretty new to drupal)
thanks for the reply & kudos on the module!

gaëlg’s picture

Assigned: Unassigned » gaëlg
Status: Postponed » Needs work

I'm on it, should be released soon.

gaëlg’s picture

Status: Needs work » Fixed

Done and released as 1.1.

lunatic’s picture

StatusFileSize
new0 bytes

Great news !!

I have trying myself to find some time to work on this issue

I had done some digging around and had "almost" a semi-functional version

Here is a patch with an alternative approach that I used on the views_navigation_get_result part

-          $real_query = $query->getSearchApiQuery();
-          $real_query->range(0, NULL);
-          $response = $real_query->execute();
+          $response = $query->getSearchApiResults();

It may save some time and resources this way, although I haven't done any bench-marking

gaëlg’s picture

I think range() is needed to ensure we get all the results with no pager limit. And the query has to be executed before we can call getSearchApiResults(): http://drupalcontrib.org/api/drupal/contributions!search_api!contrib!sea...

ada05’s picture

Hi,

Really great that you found time to work on this and extend it!

I updated the module, activated it in the view and associated a node type with the prev/next block.
The query-xxxx entries are added to the cache - However, the links are not displaying (no GET parameters generated)

I am using the SolrSearchAPI module to generate the views. Will try to investigate - maybe you have some pointers of what would have to be changed in my setup?

gaëlg’s picture

You probably use field handlers that are not yet supported by the module. A simple title field with a link to the node does not work? Do you use Search API Solr or DB?
Try to add some dpm() at strategic points of the module's code to see what happen. For example, in the 7 field handler files in views_navigation/views: if your field is supported, it should output something. The list of supported field handlers is in views_navigation_views_data_alter().

lunatic’s picture

Maybe there could be an option (for any supported field) that would return the "crafted" link as simple/raw value so it can be used as replacement on any other field ?

gaëlg’s picture

Good idea. I probably won't work on it soon, but you can open a feature request, and try to do it if you want/can. I guess the main difficulty is to find the right API way to create this views token.

ada05’s picture

@GaëlG: thanks for the hint! again: reading is key - i overlooked this info in the README.
at the moment, i am using a rendered entity - will look for a workaround - great module!-works like a charm. sorry for not reading thoroughly :)

mpv’s picture

Status: Fixed » Needs work

Great to see support for Search API. However I am getting an error with a Search API views:

Recoverable fatal error: Object of class stdClass could not be converted to string in _views_navigation_build_query() (line 228 of views_navigation/views_navigation.inc).

If I change $nids[] .= $result->entity; to $nids[] = $result->entity; the error goes away but we are still adding objects to an array that is supposed to have strings. Then array_search returns FALSE and vnp is always 0.

I've tried getting the entity id with entity_extract_ids() but the entity type is not always available. I am willing to write a patch for this but I need some directions in how we could get the entity id here.

gaëlg’s picture

Status: Needs work » Postponed (maintainer needs more info)

Do you use Search API DB? I only tested my code with Search API Solr, and $result is like this:

(Object) stdClass
    entity (Integer) 6
    _entity_properties (Array, 5 elements)
        search_api_relevance (Float) 1
        search_api_excerpt (String, 0 characters )
        search_api_item_id (String, 1 characters ) 6
        title (String, 1 characters ) a
        entity object (Object) stdClass
           ...

So that $result->entity is an integer which can be converted to a string.
Can you enable Devel module and place a dpm($result, 'result') in the code to see how your $result variable is built?

mpv’s picture

Status: Postponed (maintainer needs more info) » Needs work

Yes, I am using Search API DB. This is what I have in $result.

entity (Object) stdClass
_entity_properties (Array, 12 elements)
    search_api_relevance (String, 1 characters ) 1
    search_api_excerpt (String, 0 characters )
    search_api_id (String, 0 characters )
    item_id (String, 0 characters )
    language (String, 2 characters ) es
    entity object (Object) stdClass
      ...
_field_data (Array, 2 elements)

$result->entity is always the full entity (node in my case). Anything else I can do?

gaëlg’s picture

Assigned: gaëlg » Unassigned
Status: Needs work » Needs review

I see. Can you please test with this code instead:

        case 'search_api' :
          $node = is_object($result->entity) ? $result->entity : node_load($result->entity);
          $nids[] .= $node->nid;
          break;
mpv’s picture

Yes, that code works. I was using something similar, but I wasn't sure about assuming the entity is a node.

gaëlg’s picture

Status: Needs review » Fixed

Yes, ATM only nodes are handled. Committed to dev.

Status: Fixed » Closed (fixed)

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