drupal-graphql / graphql-search-api

GraphQL & Drupal Search API integration.
10 stars 22 forks source link

Using aggregated fields? #13

Closed rosemarystanley closed 5 years ago

rosemarystanley commented 5 years ago

I may have found a bug with using aggregated fields.

I've currently have a sitewide search I'd like to search across all selected entities (ex: Nodes and Users) So I've set up a Solr index set up with aggregated fields called "title" which includes Node "Title" field as well as a User "name" field.

First when checking in the GraphQL explorer, the aggregated fields do not appear as available fields. So I then switched my query to do fulltext search on all the full text fields available, however, this results in an internal error from PHP

Notice: Undefined variable: results in Drupal\graphql_search_api\Plugin\GraphQL\Fields\SearchAPISearch->resolveValues() (line 62 of modules/contrib/graphql_search_api/src/Plugin/GraphQL/Fields/SearchAPISearch.php).
Drupal\graphql_search_api\Plugin\GraphQL\Fields\SearchAPISearch->resolveValues(NULL, Array, Object, Object)
iterator_to_array(Object) (Line: 163)

As well as a graphql error in the drupal logs:

Call to a member function getResultItems() on null
rosemarystanley commented 5 years ago

I think I've figured out the problem I was having. I was using 2 different search_api indexes and for some reason the fields that had the same name as another index were not appearing available. So this doesn't seem to be an issue with the aggregated fields but something else. Closing this issue for now.