Skip to main content
Topic: total number of search results (prior to pagination)? (Read 4483 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

total number of search results (prior to pagination)?

This gives me the count AFTER pagination is applied...
Code: [Select]
count($context['topics'])

Is the total already available or will it require a SQL edit? Something like...
Code: [Select]
COUNT(*) AS [icode]total_count[/icode]


thanks

Re: total number of search results (prior to pagination)?

Reply #1

I guess you want it in the template, right?
It is not passed there.
With some tricks you could extract an approximation from the paginations, but to get the exact number of results, you have to edit Search.controller.php and assign the value of $num_results to an index in $context.
Bugs creator.
Features destroyer.
Template killer.

Re: total number of search results (prior to pagination)?

Reply #2

Thank you, sir. Yep, i had that idea too and have already extracted the last-page number from $context['page_index'] for another reason, i could get the approximation with that and the setting for "Number of search results per page", but this is for a semantic value so i want to be accurate. So, yep, i'm on it next.

I decided to go ahead and share this link with you.

Here's my test link for a "search results page" which is now a schema:SearchResultsPage
https://rule34.us/ontology/requests/index.php?action=search;sa=results;search=te;start=0

You can validate the semantics with Google's Structured Data Testing Tool and the W3C's RDFa Validator

I've also changed the html, see the revised headings via the W3C's HTML Validator.


Re: total number of search results (prior to pagination)?

Reply #3

How do you calculate the relevance? :D
Bugs creator.
Features destroyer.
Template killer.

Re: total number of search results (prior to pagination)?

Reply #4

Table: elkarte_log_search_results has a relevance column :D
LiveGallery - Simple gallery addon for ElkArte

Re: total number of search results (prior to pagination)?

Reply #5

re: relevance
I was surprised it wasn't output to the search-results page already. I'm going to go back to this and expose the search-weight settings as well. That info would be, um, relevant to the semantic value for the schema:SearchAction's query property's -output constraints.

Re: total number of search results (prior to pagination)?

Reply #6

Search is Spuds' domain. xD
Bugs creator.
Features destroyer.
Template killer.

Re: total number of search results (prior to pagination)?

Reply #7

(idk if you want this post here or elsewhere but it's related to this work)
Here's a search example returning both a Topic and a Reply. The missing datePublished is for the Reply's parent, a Topic. So that's another hack needed.

Re: total number of search results (prior to pagination)?

Reply #8

and this is how we fail query too short

Re: total number of search results (prior to pagination)?

Reply #9

Good stuff ... I think adding Structured Data would be a very good thing to do in 2.0.

I've dabbled with it, but only using ld+json output in the templates, and then only for the topic listing, never considered getting in to the other templates such as search.  What is the benefit of using it on the search page (honest question). 

Re: total number of search results (prior to pagination)?

Reply #10

The benefits of linked-data, first, let's hear from the man himself.
https://www.youtube.com/watch?v=OM6XIICm_qo&t=18s

k, posting that real quick and typing my 2cents to append here (which should answer your question and hopefully demystifies linked-data for everyone). ...to be continued...


Re: total number of search results (prior to pagination)?

Reply #11

Expanding upon that. So the web is a decentralized documentation system, right? Well, linked-data is a decentralized database, a hierarchy of concepts, a built-in axiomatic proofing system, the definitive answer to localization.



Machines are dumber-than-children idiots, incapable of abstract concepts, a process which we take for granted. But, if we define our objects (and link them together with relationships), machines are able to reason.
Without semantics, this is simply a block of text which is full-text searched by Google matching only the literal characters of the text, i.e. an exact-word match.
QuoteJill is pregnant.
but with semantics:
A machine can take this minimum input...
Quote<span typeof="Person"><span property="name">Jill</span></span> is pregnant.
And can produce this output about Jill on its own:
Quote<span typeof="Person"><span property="name">Jill</span></span>is pregnant. Only women Persons may be pregnant, so Jill must be a woman.
as a fact, and this as a guess...

Quote<span typeof="Person"><span property="name">Jill</span></span> is a pregnant woman Person whom might benefit from a list of OBGYNs near her geo-location.

which is a different outcome from
Quote<span typeof="Canine"><span property="name">Jill</span></span> is a pregnant female Dog whom probably has an owner who might be looking for an address to an animal shelter


And that's not even scratching the surface of the benefits, many of which are unknown until we reach a certain point in world-wide implementation (like we did with the old web).

Had much more to say about it but gotta roll, but specifically about the search/search-results pages...

Search is the most important feature of ANY site (and the web itself, for that matter), it's what we do the most online. The search feature is undoubtedly the best entry point to (potentially) any piece of data in its scope. So, in my estimation it's the best place to apply my semantic-efforts.

Also, there's Google's "Sitelinks Searchbox" --but just because you have the correct markup for the schema:SearchAction (and mine is correct and then some), doesn't mean you'll get the Searchbox in your SERs, there are still many factors weighing your relevancy to the user's search. Regardless, it's an in-the-wild example of what is possible with this technology.

tl;d review


More about linked-data from one of the author's of JSON-LD.

https://www.youtube.com/watch?v=4x_xzT5eF5Q

Btw, you've been using a semantic search via Google since Aug. 2013
Last Edit: May 20, 2017, 04:31:05 am by Atlas

Re: total number of search results (prior to pagination)?

Reply #12

Quote from: Atlas – (idk if you want this post here or elsewhere but it's related to this work)
Here's a search example returning both a Topic and a Reply. The missing datePublished is for the Reply's parent, a Topic. So that's another hack needed.
If I'm not wrong, you may have it in either:
Code: [Select]
$message['first_post']['time']
$message['first_post']['html_time']
$message['first_post']['timestamp']
Bugs creator.
Features destroyer.
Template killer.

Re: total number of search results (prior to pagination)?

Reply #13

Quote from: emanuele –
Quote from: Atlas – (idk if you want this post here or elsewhere but it's related to this work)
Here's a search example returning both a Topic and a Reply. The missing datePublished is for the Reply's parent, a Topic. So that's another hack needed.
If I'm not wrong, you may have it in either:
Code: [Select]
$message['first_post']['time']
$message['first_post']['html_time']
$message['first_post']['timestamp']
didn't work

Re: total number of search results (prior to pagination)?

Reply #14

Blame me for looking at 1.1 code instead of 1.0... sorry for the noise. xD
Bugs creator.
Features destroyer.
Template killer.