Page 1 of 1

Obtaining accurate result count

Posted: Sun Sep 19, 2004 11:57 pm
by james120
$rows.max only seems to return an accurate value if likeprows is not reached. For instance, if you do a query that has 25,000 possible results, and likeprows is set to 100, but $max is set to 50, $max.rows will say 25,000. But, if $max is set to 500, so that likeprows becomes the limiting factor instead of $max, then it tells you that there are 100 results in the query. How do you consistently report how many results there are for a query, regardless of how many you intend to show?

Obtaining accurate result count

Posted: Mon Sep 20, 2004 10:44 am
by John
$rows.max starts off set to $indexcount, which you can also look at. If the end of the results are found then $rows.max is set to where the end was.

Obtaining accurate result count

Posted: Mon Sep 20, 2004 5:50 pm
by james120
$indexcount is always accurate once the query is completed, right?

Obtaining accurate result count

Posted: Mon Sep 20, 2004 5:57 pm
by John
$indexcount does not change from the first to the last result, and will be the number of rows the index said might match. If post processing is required then the actual number of results may be smaller. If no index can be used $indexcount will be 0.

Obtaining accurate result count

Posted: Thu Jul 13, 2006 8:55 am
by Texis User
Hi,
For a particular searchString, my liker query returns only 100 records (verified in database).

But the indexCount returns 6710.

My understanding by this is, indexCount merely is number of matches not records(i.e. One record could have ~100 matches and so on).

Since numrows takes indexcount for total number of records,no of pages calculated is incorrect too.

So how do you know, how many results there are for a query, regardless of how many you intend to show?

Obtaining accurate result count

Posted: Thu Jul 13, 2006 9:21 am
by John
indexcount returns the number of matching records. By default LIKER and LIKEP only returns the best 100 matching records. You can change that with the likeprows setting.

Obtaining accurate result count

Posted: Thu Jul 13, 2006 10:29 am
by Texis User
How do we control <pagelinks>.
I increased MAXPGS to 20 as you see below.

<pagelinks MAXPGS=20 SUMFUNC =sumfunc PREVFUNC=prevfunc NEXTFUNC=nextfunc >

Now $pg gets calculated from $indexCount.So it shows 20 links but since the likeprows is set to 100 when we click on 2nd page it throws error(MAX is 100).

Is there any other workaround?

Obtaining accurate result count

Posted: Thu Jul 13, 2006 10:52 am
by John
Use <SQL "set likeprows = 200"></SQL> or however large a number you will let users scroll through results.

Obtaining accurate result count

Posted: Fri Jan 19, 2007 5:51 am
by josmani
I need to get an accurate result count on a query in which I use "group by" clause. All the count methods I used return the count before applying the "group by".

In the following example:

select count(ID) DOCS, CATEGORY from mytable group by CATEGORY;

$indexcount will return count of all record. Is there another method that I should be using?

Obtaining accurate result count

Posted: Fri Jan 19, 2007 11:14 am
by John
The simplest way in that case is either look at the number of results after the query (e.g. $loop in Vortex), or a

select count (distinct CATEGORY) from mytable;

if you want to know before.