How to count the number of hits in each abstract

Post Reply
User avatar
John
Site Admin
Posts: 2612
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

Re: How to count the number of hits in each abstract

Post by John »

The code now selects the Abstract directly from the database, and you can do the same with dnum.

You should see code like:

Code: Select all

   <$resultVars = $resultVars "Abstract">
   <makeAbstractSqlExpression>
   <$resultVarExps = $resultVarExps $ret>
that selects the Abstract.

After that you would want something like:

Code: Select all

<$resultVars = $resultVars "dnumhits">
<strfmt $qsrchfmt $txtquery>
<queryfixup var=$ret>
<$cleanMMQuery=$ret>
<$resultVarExps = $resultVarsExps "mminfo ($$cleanMMQuery,Body, 0,0, 6) - '203 hits: '">
I haven't actually tested the code in the script, but the SQL expression works, and should return the dnumhits variable.
John Turnbull
Thunderstone Software
User avatar
John
Site Admin
Posts: 2612
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

Re: How to count the number of hits in each abstract

Post by John »

I had a type in this line:

Code: Select all

<$resultVarExps = $resultVarsExps "mminfo ($$cleanMMQuery,Body, 0,0, 6) - '203 hits: '">
both variables should have been the same:

Code: Select all

<$resultVarExps = $resultVarExps "mminfo ($$cleanMMQuery,Body, 0,0, 6) - '203 hits: '">
John Turnbull
Thunderstone Software
User avatar
John
Site Admin
Posts: 2612
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

Re: How to count the number of hits in each abstract

Post by John »

You shouldn't have needed to make that change. Adding dnumhits to resultVars should have put the result into $dnumhits.
John Turnbull
Thunderstone Software
User avatar
John
Site Admin
Posts: 2612
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

Re: How to count the number of hits in each abstract

Post by John »

There are a few nuances to how a hit is defined. The following code should work for you, it adds one line after the queryfixup so that every occurrence of every term in the search will count as a hit:

Code: Select all

<$resultVars = $resultVars "dnumhits">
<strfmt $qsrchfmt $txtquery>
<queryfixup var=$ret>
<strfmt "%s @0 w/." $ret>
<$cleanMMQuery=$ret>
<$resultVarExps = $resultVarExps "mminfo ($$cleanMMQuery,Body, 0,0, 6) - '203 hits: '">
John Turnbull
Thunderstone Software
User avatar
John
Site Admin
Posts: 2612
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

Re: How to count the number of hits in each abstract

Post by John »

Most likely

Code: Select all

$dnumhits
has all the results in it, but you are only displaying the first one. You would need to make sure you are iterating over the list similar to the other display variables.
John Turnbull
Thunderstone Software
Post Reply