}
+// Look up a facet term, and return matching id
+// If facet type not found, returns 0
+// If facet type found, but no matching term, returns ""
const char *session_lookup_id_facet(struct session *s, struct client *cl,
const char *type,
const char *term)
{
+ char *retval = 0;
struct facet_id *t = s->facet_id_list;
- for (; t; t = t->next)
- if (!strcmp(client_get_id(cl), t->client_id) &&
- !strcmp(t->type, type) && !strcmp(t->term, term))
+ for (; t; t = t->next)
+ {
+ if (!strcmp(client_get_id(cl), t->client_id) && !strcmp(t->type, type) )
{
- return t->id;
+ retval = "";
+ if ( !strcmp(t->term, term))
+ {
+ return t->id;
+ }
}
- return 0;
+ }
+ return retval;
}
void add_facet(struct session *s, const char *type, const char *value, int count, struct client *cl)
l->next = se->clients_cached;
se->clients_cached = l;
}
- /* set session always. If may be 0 if client is not active */
client_set_session(cl, se);
l = xmalloc(sizeof(*l));
client_lock(l->client);
client_set_session(l->client, 0);
client_set_database(l->client, 0);
+ client_mark_dead(l->client);
client_unlock(l->client);
client_destroy(l->client);
xfree(l);
break;
if (sr)
{
- session_log(se, YLOG_DEBUG, "session_sort: field=%s increasing=%d type=%d already fetched",
+ session_log(se, YLOG_LOG, "session_sort: field=%s increasing=%d type=%d already fetched",
field, increasing, type);
session_leave(se, "session_sort");
return;
struct client *cl = l->client;
// Assume no re-search is required.
client_parse_init(cl, 1);
- clients_research += client_parse_sort(cl, sp);
+ clients_research += client_parse_sort(cl, sp, 0);
}
if (!clients_research || se->clients_starting)
{
}
session_enter(se, "session_sort");
se->clients_starting = 0;
+ se->force_position = 0;
session_leave(se, "session_sort");
}
}
int no_working = 0;
int no_failed_query = 0;
int no_failed_limit = 0;
+ int no_sortmap = 0;
struct client_list *l;
session_log(se, YLOG_DEBUG, "Search");
return PAZPAR2_NO_ERROR;
}
se->clients_starting = 1;
+ se->force_position = 0;
session_leave(se, "session_search0");
if (se->settings_modified) {
*addinfo = "limit";
session_leave(se, "session_search");
se->clients_starting = 0;
+ session_reset_active_clients(se, 0);
return PAZPAR2_MALFORMED_PARAMETER_VALUE;
}
else
{
client_parse_range(cl, startrecs, maxrecs);
- client_parse_sort(cl, sp);
+ client_parse_sort(cl, sp, &no_sortmap);
client_start_search(cl);
no_working++;
}
}
+ yaz_log(YLOG_LOG, "session_search: no_working=%d no_sortmap=%d",
+ no_working, no_sortmap);
session_enter(se, "session_search2");
+ if (no_working == 1 && no_sortmap == 1)
+ {
+ se->force_position = 1;
+ yaz_log(YLOG_LOG, "force_position=1");
+ }
se->clients_starting = 0;
session_leave(se, "session_search2");
if (no_working == 0)
session->mergekey = 0;
session->rank = 0;
session->clients_starting = 0;
+ session->force_position = 0;
for (i = 0; i <= SESSION_WATCH_MAX; i++)
{
struct reclist_sortparms *spp;
struct client_list *l;
int i;
+ NMEM nmem_tmp = 0;
#if USE_TIMING
yaz_timing_t t = yaz_timing_create();
#endif
*approx_hits += client_get_approximation(l->client);
}
}
+ if (se->force_position)
+ {
+ nmem_tmp = nmem_create();
+ sp = reclist_parse_sortparms(nmem_tmp, "position:1", 0);
+ assert(sp);
+ }
reclist_sort(se->reclist, sp);
+ if (nmem_tmp)
+ nmem_destroy(nmem_tmp);
reclist_enter(se->reclist);
*total = reclist_get_num_records(se->reclist);