Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a report of keywords searched for #64

Open
mjordan opened this issue Nov 26, 2020 · 2 comments
Open

Add a report of keywords searched for #64

mjordan opened this issue Nov 26, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@mjordan
Copy link
Owner

mjordan commented Nov 26, 2020

No description provided.

@mjordan mjordan added the enhancement New feature or request label Nov 26, 2020
@mjordan
Copy link
Owner Author

mjordan commented Nov 28, 2020

The following simple module captures the current search via the current request URL and the number of results:

<?php

/**
 * @file
 * Testing search API stuff.
 */

use Drupal\search_api\Query\ResultSetInterface;

/**
 * Implements hook_search_api_results_alter().
 */
function mjtest_search_api_results_alter(ResultSetInterface &$results) {
  $current_uri = \Drupal::request()->getRequestUri();
  devel_debug($current_uri);

  devel_debug($results->getResultCount());
}

mjordan added a commit that referenced this issue Nov 28, 2020
mjordan added a commit that referenced this issue Nov 29, 2020
@mjordan
Copy link
Owner Author

mjordan commented Nov 29, 2020

Using parse_str(), we can get arrays like this from the search query string:

Array
(
    [/solr-search/content?search_api_fulltext] => thesis
    [f] => Array
        (
            [0] => sfu_department_program:Applied Science: School of Engineering Science
        )

)
Array
(
    [/solr-search/content?search_api_fulltext] => analysis defect seeing
)
Array
(
    [/solr-search/content?search_api_fulltext] => thesis
    [page] => 2
)

So reports on the search terms, facets used, and pagination could be created. Another useful report is searches that resulted in 0 hits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant