Page 1 of 1

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

Posted: Tue May 14, 2024 10:42 am
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.

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

Posted: Wed May 15, 2024 2:12 pm
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: '">

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

Posted: Fri May 24, 2024 11:44 am
by John
You shouldn't have needed to make that change. Adding dnumhits to resultVars should have put the result into $dnumhits.

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

Posted: Mon May 27, 2024 10:15 am
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: '">

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

Posted: Tue May 28, 2024 8:24 am
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.