A block with top searches would be usefull.

Lists with Top search terms, top suggestions, misspelled search terms.

Export of above lists in a csv or excel file.

Comments

janusman’s picture

Title: Top search terms, ....... » Top search terms
Status: Active » Needs review
StatusFileSize
new19.81 KB
new2.23 KB

I like the idea of a block!

Here's a patch to start things off, and a screenshot as to how it looks. (code will report the top 25 terms within the report span, but my current test environment didn't have too much data on it) =)

2010-02-15_175605.png

bennos’s picture

for a first overview this is great.

To improve the quality of searching, it is usefull to have more detailed list with keys, suggested keys.
Reporting is always good.

janusman’s picture

When you mention "suggested keys", you mean you want a rundown of the most-suggested replacements?

Like:
--------------------------------------------------
Top suggested keywords: test (55), thing (32)
--------------------------------------------------

Or would you like to know what the original keyword AND the suggestions were:
--------------------------------------------------
Top suggestions:
* testing => test (55)
* thong => thing (32)
--------------------------------------------------

janusman’s picture

Oh another thing the patch is for tallying WORDS instead of phrases; maybe it might be best to use search phrases instead.

Meaning, if a user typed in "books about testing" right now I'm tallying 3 separate words: "books", "about" and "testing", but it might be better to tally the whole phrase.

janusman’s picture

Status: Needs review » Active
StatusFileSize
new2.72 KB
new23.41 KB

Ok, I'm still missing how the search suggestions should be tracked, for now I committed the attached patch to 6.x-1.x-DEV that provides basic tracking of search phrases:

2010-02-16_221804.png

Leaving open for discussing tracking of suggestion keywords.

bennos’s picture

will try the patch.

Or would you like to know what the original keyword AND the suggestions were:
--------------------------------------------------
Top suggestions:
* testing => test (55)
* thong => thing (32)
--------------------------------------------------

this would be better, because the typing mistakes are showed. If there are several misstakes, we can improve the solr index.

bennos’s picture

Hi

have installed the Dev version for some time. currently it is a good starting point.

geerlingguy’s picture

Subscribe. I'll download -dev and try it out soon.

mikebell_’s picture

StatusFileSize
new1.89 KB

Here is a patch that adds a very (emphasis on very) basic block to display your sites top 10 most popular phrases.

It still needs a lot of work, but it's a starting point.

laroccadahouse’s picture

i've got this popularblock.patch running on a development site and would like to have a weighted display. is there a way of making the original top searches patch output a block as well instead of two separate functions?

janusman’s picture

I dont think we should use the exact same code, since there are differences:

- the report page is exhaustive (counts ALL search terms in the desired date range), and places a heavy(er?) load on the server, but is supposed to be viewed only by admins.
- a block would probably be requested to be rendered very often by different users, and probably doesnt need an exhaustive dataset.

So I'm thinking of a less expensive query to build the terms, sort of like this:

// Return keywords only last week's logged queries.
$result = db_query_range("SELECT keywords FROM {apachesolr_stats} WHERE
      numfound > 0 AND timestamp > (unix_timestamp() - 3600*24*7)
      ORDER BY timestamp DESC", 0, 5000);

Working on this right now, in fact. We *definitely* also want to cache this, say, for at least 30 minutes.

janusman’s picture

Status: Active » Needs review
StatusFileSize
new2.56 KB

Patch for review. Probably will commit this soon, would love some feedback.

janusman’s picture

Committed to 6.x-1.x branch.

janusman’s picture

Status: Needs review » Fixed
laroccadahouse’s picture

Thank you for the quick response. I applied your patch, no issues there, but I don't really see how this is different than the previous patch in what it outputs. But that does not mean much as I only know enough php to do damage.

I probably should have been a bit more detailed in what I am trying to get out of this block. I really like how the items display with the number for each keyword as well as varying font sizes depending on that number on the stats page.

Again thank you for your help.

janusman’s picture

Status: Fixed » Active

I get it. Hmm, well, the *way* the results are output IMO should be by default relatively clean, and then anyone could override that look in their own theme.

The thing is: right now it's not overridable, since I just stuck all the contents into an array and just pipe it thru theme('item_list', $links);

... it'd be better to:
1) Have a function that just calculates the top words and returns a list with words and frequencies
2) have a theming function that converts the above into whatever kind of list (by default I think it could *just* be a listing, but with some added classes, and stylesheet for font size). So this function would return HTML, and could then be overridden by any theme/module.

So, marking as active again. Patches welcome!

laroccadahouse’s picture

Agreed about letting anyone override the look in their own theme. This would allow some to maintain it as just an item list and some to be more creative depending on their own uses. I am very comfortable with having the function return HTML with added classes for custom styling. I imagine something similar to the views cloud output.

laroccadahouse’s picture

any updates?

janusman’s picture

None yet! Patches, code, coffee, chocolate, beer, etc. welcome!

janusman’s picture

Status: Active » Fixed

I added a simple theme_ function; this is now committed in Git... hopefully the new dev version will be rolled by Drupal.org soon.

Thanks!

Status: Fixed » Closed (fixed)

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