limitmap: don't use CCL limitmap for relevancy ranking
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 18 Sep 2012 12:40:16 +0000 (14:40 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 18 Sep 2012 12:40:16 +0000 (14:40 +0200)
Only the CCL from query is in use for relevancy ranking now.

src/client.c
test/test_http_60.res
test/test_limit_limitmap_15.res

index 3578173..9f86ce6 100644 (file)
@@ -1083,17 +1083,12 @@ const char *client_get_facet_limit_local(struct client *cl,
 
 static int apply_limit(struct session_database *sdb,
                        facet_limits_t facet_limits,
-                       WRBUF w_pqf, WRBUF w_ccl,
-                       CCL_bibset ccl_map)
+                       WRBUF w_pqf, CCL_bibset ccl_map)
 {
     int ret = 0;
     int i = 0;
     const char *name;
     const char *value;
-    const char **and_op_names = ccl_qual_search_special(ccl_map, "and");
-    const char *and_op = and_op_names ? and_op_names[0] : "and";
-    const char **or_op_names = ccl_qual_search_special(ccl_map, "or");
-    const char *or_op = or_op_names ? or_op_names[0] : "or";
 
     NMEM nmem_tmp = nmem_create();
     for (i = 0; (name = facet_limits_get(facet_limits, i, &value)); i++)
@@ -1128,20 +1123,34 @@ static int apply_limit(struct session_database *sdb,
                 else if (!strncmp(s->value, "ccl:", 4))
                 {
                     const char *ccl = s->value + 4;
-                    
-                    wrbuf_printf(w_ccl, " %s (", and_op);
-
+                    WRBUF ccl_w = wrbuf_alloc();
                     for (i = 0; i < num; i++)
                     {
-                        if (i)
-                            wrbuf_printf(w_ccl, " %s ", or_op);
-                        wrbuf_puts(w_ccl, ccl);
-                        wrbuf_puts(w_ccl, "=\"");
-                        wrbuf_puts(w_ccl, values[i]);
-                        wrbuf_puts(w_ccl, "\"");
+                        int cerror, cpos;
+                        struct ccl_rpn_node *cn;
+
+                        wrbuf_rewind(ccl_w);
+                        wrbuf_puts(ccl_w, ccl);
+                        wrbuf_puts(ccl_w, "=\"");
+                        wrbuf_puts(ccl_w, values[i]);
+                        wrbuf_puts(ccl_w, "\"");
+
+                        cn = ccl_find_str(ccl_map, wrbuf_cstr(ccl_w), 
+                                          &cerror, &cpos);
+                        if (cn)
+                        {
+                            if (i == 0)
+                                wrbuf_printf(w_pqf, "@and ");
+
+                            /* or multiple values.. could be bad if last CCL
+                               parse fails, but this is unlikely to happen */
+                            if (i < num - 1)
+                                wrbuf_printf(w_pqf, "@or ");
+                            ccl_pquery(w_pqf, cn);
+                            ccl_rpn_delete(cn);
+                        }
                     }
-                    wrbuf_puts(w_ccl, ")");
-
+                    wrbuf_destroy(ccl_w);
                 }
                 else if (!strncmp(s->value, "local:", 6)) {
                     /* no operation */
@@ -1214,7 +1223,7 @@ int client_parse_query(struct client *cl, const char *query,
         wrbuf_puts(w_pqf, " ");
     }
 
-    if (apply_limit(sdb, facet_limits, w_pqf, w_ccl, ccl_map))
+    if (apply_limit(sdb, facet_limits, w_pqf, ccl_map))
     {
         ccl_qual_rm(&ccl_map);
         return -2;
index ea3a20e..a0046a5 100644 (file)
@@ -26,7 +26,7 @@
 <md-test-usersetting>XXXXXXXXXX</md-test-usersetting>
 <md-test-usersetting-2>test-usersetting-2 data: 
         YYYYYYYYY</md-test-usersetting-2></location>
-<relevance>429749</relevance>
+<relevance>291121</relevance>
 <recid>content: title the religious teachers of greece author adam james medium book</recid>
 </hit>
 </show>
\ No newline at end of file
index 1bb23c0..0c2b760 100644 (file)
@@ -17,7 +17,7 @@
 <md-author>Adam, James</md-author>
 <md-description>Reprint of the 1909 ed., which was issued as the 1904-1906 Gifford lectures</md-description>
 <md-test-usersetting>XXXXXXXXXX</md-test-usersetting></location>
-<relevance>429749</relevance>
+<relevance>291121</relevance>
 <recid>content: title the religious teachers of greece author adam james</recid>
 </hit>
 </show>
\ No newline at end of file