From: Dennis Schafroth Date: Wed, 22 Aug 2012 14:32:15 +0000 (+0200) Subject: Only reseting on position, when not done before. Otherwise it would reset on every... X-Git-Tag: v1.6.16~3 X-Git-Url: http://git.indexdata.com/?a=commitdiff_plain;h=50aa60919772aeee3ac23a4a5e67a3d6e09a4770;p=pazpar2-moved-to-github.git Only reseting on position, when not done before. Otherwise it would reset on every pull by the client --- 50aa60919772aeee3ac23a4a5e67a3d6e09a4770 diff --cc src/http_command.c index aa73f91,4575ef3..7676eef --- a/src/http_command.c +++ b/src/http_command.c @@@ -1188,8 -1188,9 +1188,9 @@@ static void cmd_show(struct http_channe release_session(c, s); return; } - session_sort(s->psession, sp->name, sp->increasing, - sp->type == Metadata_sortkey_position); - session_sort(s->psession, sp->name, sp->increasing, 0); ++ session_sort(s->psession, sp->name, sp->increasing, sp->type == Metadata_sortkey_position); + /* TODO This was too simple. Will make pazpar2 continuing reseting the session resultset and redo the search. Disable this for now + sp->type == Metadata_sortkey_position */ status = session_active_clients(s->psession); diff --cc src/session.c index 008a617,0d463d6..6ac2276 --- a/src/session.c +++ b/src/session.c @@@ -649,33 -647,38 +649,34 @@@ void session_sort(struct session *se, c session_enter(se); - yaz_log(YLOG_LOG, "session_sort field=%s", field); - // TODO In order for this to work, clear_set may only be true on first call. Every following (poll) may not. - // I do not think we can decide this from the outside of the session. - // The logic should be when we change to/away from a native sort order, - // it should cleared on the first call - if (clear_set) + yaz_log(YLOG_LOG, "session_sort field=%s increasing=%d position=%d", field, increasing, position); + /* see if we already have sorted for this critieria */ ++ /* TODO I do not see the point in saving all previous sorts. Dont we re-sort anyway ? */ + for (sr = se->sorted_results; sr; sr = sr->next) { - session_clear_set(se, field, increasing); + if (!strcmp(field, sr->field) && increasing == sr->increasing && sr->position == position) + break; } - else + if (sr) { - z(se, YLOG_DEBUG, "search_sort: field=%s increasing=%d position=%d already fetched", - /* see if we already have sorted for this critieria */ - for (sr = se->sorted_results; sr; sr = sr->next) - { - if (!strcmp(field, sr->field) && increasing == sr->increasing) - break; - } - if (sr) - { - session_log(se, YLOG_DEBUG, "search_sort: field=%s increasing=%d already fetched", - field, increasing); - session_leave(se); - return; - } - session_log(se, YLOG_DEBUG, "search_sort: field=%s increasing=%d must fetch", - field, increasing); - sr = nmem_malloc(se->nmem, sizeof(*sr)); - sr->field = nmem_strdup(se->nmem, field); - sr->increasing = increasing; - sr->next = se->sorted_results; - se->sorted_results = sr; ++ session_log(se, YLOG_DEBUG, "search_sort: field=%s increasing=%d position=%d already fetched", + field, increasing, position); + session_leave(se); + return; } + if (position) + { + session_clear_set(se, field, increasing, position); + } + - session_log(se, YLOG_DEBUG, "search_sort: field=%s increasing=%d must fetch", - field, increasing); ++ session_log(se, YLOG_DEBUG, "search_sort: field=%s increasing=%d position=%d must fetch", ++ field, increasing, position); + sr = nmem_malloc(se->nmem, sizeof(*sr)); + sr->field = nmem_strdup(se->nmem, field); + sr->increasing = increasing; + sr->position = position; + sr->next = se->sorted_results; + se->sorted_results = sr; for (l = se->clients_active; l; l = l->next) { @@@ -695,7 -698,7 +696,8 @@@ enum pazpar2_error_code session_search( const char *filter, const char *limit, const char **addinfo, -- const char *sort_field, int increasing) ++ const char *sort_field, ++ int increasing) { int live_channels = 0; int no_working = 0; @@@ -716,7 -719,7 +718,7 @@@ session_enter(se); se->settings_modified = 0; -- session_clear_set(se, sort_field, increasing); ++ session_clear_set(se, sort_field, increasing, 0); /* hardcoded position */ relevance_destroy(&se->relevance); live_channels = select_targets(se, filter); diff --cc test/test_limit_limitmap.urls index a56d6c1,a56d6c1..4e03d25 --- a/test/test_limit_limitmap.urls +++ b/test/test_limit_limitmap.urls @@@ -6,7 -6,7 +6,7 @@@ http://localhost:9763/search.pz2?sessio http://localhost:9763/search.pz2?session=1&command=termlist&block=1&name=xtargets%2Cauthor%2Csubject%2Cdate test_limit_limitmap_settings_2.xml http://localhost:9763/search.pz2?session=1&command=settings http://localhost:9763/search.pz2?session=1&command=search&query=computer --4 http://localhost:9763/search.pz2?session=1&command=show&block=1 ++10 http://localhost:9763/search.pz2?session=1&command=show&block=1 http://localhost:9763/search.pz2?session=1&command=bytarget http://localhost:9763/search.pz2?session=1&command=termlist&block=1&name=xtargets%2Cauthor%2Csubject%2Cdate http://localhost:9763/search.pz2?session=1&command=termlist&block=1&report=status&name=xtargets%2Cauthor%2Csubject%2Cdate @@@ -28,4 -28,4 +28,16 @@@ http://localhost:9763/search.pz2?sessio 1 http://localhost:9763/search.pz2?session=1&command=show&block=1&version=2 http://localhost:9763/search.pz2?session=1&command=search&query=computer&limit=date%3D1977 http://localhost:9763/search.pz2?session=1&command=show&block=1&version=2 ++http://localhost:9763/search.pz2?session=1&command=termlist&block=1&version2= ++http://localhost:9763/search.pz2?session=1&command=search&query=computer&limit=date%3C1977 ++http://localhost:9763/search.pz2?session=1&command=show&block=1&version=2 ++http://localhost:9763/search.pz2?session=1&command=termlist&block=1&version=2 ++http://localhost:9763/search.pz2?session=1&command=search&query=computer&limit=date%3D1977-1997 ++http://localhost:9763/search.pz2?session=1&command=show&block=1&version=2 ++http://localhost:9763/search.pz2?session=1&command=termlist&block=1&version2= ++http://localhost:9763/search.pz2?session=1&command=search&query=computer&limit=date%3C1977 ++http://localhost:9763/search.pz2?session=1&command=show&block=1&version=2 http://localhost:9763/search.pz2?session=1&command=termlist&block=1&version=2 ++http://localhost:9763/search.pz2?session=1&command=search&query=computer&limit=date%3D1977-1997 ++http://localhost:9763/search.pz2?session=1&command=show&block=1&version=2 ++http://localhost:9763/search.pz2?session=1&command=termlist&block=1&version2= diff --cc test/test_limit_limitmap_31.res index 49ad793,49ad793..3acc441 --- a/test/test_limit_limitmap_31.res +++ b/test/test_limit_limitmap_31.res @@@ -20,9 -20,9 +20,6 @@@ Target-1 ztest-db1 10 --4 --4 --6 Client_Idle 0 diff --cc test/test_limit_limitmap_settings_1.xml index fe94c47,fe94c47..deaa865 --- a/test/test_limit_limitmap_settings_1.xml +++ b/test/test_limit_limitmap_settings_1.xml @@@ -12,6 -12,6 +12,7 @@@ ++ diff --cc test/test_limit_limitmap_settings_2.xml index 4fbbdf2,4fbbdf2..656062a --- a/test/test_limit_limitmap_settings_2.xml +++ b/test/test_limit_limitmap_settings_2.xml @@@ -5,7 -5,7 +5,7 @@@ -- ++ @@@ -22,9 -22,9 +22,10 @@@ -- ++ ++