For searches, allow truncmax value to be controlled with attribute 13.
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 17 Jan 2007 12:59:38 +0000 (12:59 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 17 Jan 2007 12:59:38 +0000 (12:59 +0000)
If given, that overrides the value of 'truncmax'.

NEWS
doc/querymodel.xml
index/rpnsearch.c

diff --git a/NEWS b/NEWS
index d1c489c..f2ce8cf 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+For searches, allow truncmax value to be controlled with attribute 13.
+If given, that overrides the value of 'truncmax'.
+
 For truncations being limited (abort at truncmax terms), zebrasrv returns
 SearchResponse with resultSetStatus=subset.
 
index 3a3f781..cdb344d 100644 (file)
@@ -1,5 +1,5 @@
  <chapter id="querymodel">
-  <!-- $Id: querymodel.xml,v 1.27 2006-11-30 10:33:19 adam Exp $ -->
+  <!-- $Id: querymodel.xml,v 1.28 2007-01-17 12:59:38 adam Exp $ -->
   <title>Query Model</title>
   
   <section id="querymodel-overview">
        <entry>2.0.8</entry>
        </row>
       </tbody>
+       <row>
+       <entry>Maximum number of truncated terms (truncmax)</entry>
+       <entry>13</entry>
+       <entry>search</entry>
+       <entry>2.0.10</entry>
+       </row>
      </tgroup>
     </table>      
     
index f581512..98fc69d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rpnsearch.c,v 1.7 2007-01-16 15:31:23 adam Exp $
+/* $Id: rpnsearch.c,v 1.8 2007-01-17 12:59:38 adam Exp $
    Copyright (C) 1995-2007
    Index Data ApS
 
@@ -1210,10 +1210,6 @@ static ZEBRA_RES grep_info_prepare(ZebraHandle zh,
                                   struct grep_info *grep_info,
                                   int reg_type)
 {
-    AttrType termset;
-    int termset_value_numeric;
-    const char *termset_value_string;
-
 #ifdef TERM_COUNT
     grep_info->term_no = 0;
 #endif
@@ -1223,35 +1219,50 @@ static ZEBRA_RES grep_info_prepare(ZebraHandle zh,
     grep_info->zh = zh;
     grep_info->reg_type = reg_type;
     grep_info->termset = 0;
-    if (!zapt)
-        return ZEBRA_OK;
-    attr_init_APT(&termset, zapt, 8);
-    termset_value_numeric =
-        attr_find_ex(&termset, NULL, &termset_value_string);
-    if (termset_value_numeric != -1)
+    if (zapt)
+    {
+        AttrType truncmax;
+        int truncmax_value;
+
+        attr_init_APT(&truncmax, zapt, 13);
+        truncmax_value = attr_find(&truncmax, NULL);
+        if (truncmax_value != -1)
+            grep_info->trunc_max = truncmax_value;
+    }
+    if (zapt)
     {
+        AttrType termset;
+        int termset_value_numeric;
+        const char *termset_value_string;
+
+        attr_init_APT(&termset, zapt, 8);
+        termset_value_numeric =
+            attr_find_ex(&termset, NULL, &termset_value_string);
+        if (termset_value_numeric != -1)
+        {
 #if TERMSET_DISABLE
-        zebra_setError(zh, YAZ_BIB1_UNSUPP_SEARCH, "termset");
-        return ZEBRA_FAIL;
+            zebra_setError(zh, YAZ_BIB1_UNSUPP_SEARCH, "termset");
+            return ZEBRA_FAIL;
 #else
-        char resname[32];
-        const char *termset_name = 0;
-        if (termset_value_numeric != -2)
-        {
-    
-            sprintf(resname, "%d", termset_value_numeric);
-            termset_name = resname;
-        }
-        else
+            char resname[32];
+            const char *termset_name = 0;
+            if (termset_value_numeric != -2)
+            {
+                
+                sprintf(resname, "%d", termset_value_numeric);
+                termset_name = resname;
+            }
+            else
             termset_name = termset_value_string;
-        yaz_log(log_level_rpn, "creating termset set %s", termset_name);
-        grep_info->termset = resultSetAdd(zh, termset_name, 1);
-        if (!grep_info->termset)
-        {
-           zebra_setError(zh, YAZ_BIB1_ILLEGAL_RESULT_SET_NAME, termset_name);
-            return ZEBRA_FAIL;
-        }
+            yaz_log(log_level_rpn, "creating termset set %s", termset_name);
+            grep_info->termset = resultSetAdd(zh, termset_name, 1);
+            if (!grep_info->termset)
+            {
+                zebra_setError(zh, YAZ_BIB1_ILLEGAL_RESULT_SET_NAME, termset_name);
+                return ZEBRA_FAIL;
+            }
 #endif
+        }
     }
     return ZEBRA_OK;
 }