From: Adam Dickmeiss Date: Tue, 16 Jun 2015 10:42:14 +0000 (+0200) Subject: Sort by retrieval PAZ-1006 X-Git-Tag: v1.10.0~1 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=a3f57f20fb1ade51cc5a99aafcc16af1a1f5b0c8;p=pazpar2-moved-to-github.git Sort by retrieval PAZ-1006 --- diff --git a/doc/pazpar2_protocol.xml b/doc/pazpar2_protocol.xml index 4629cbf..28545e6 100644 --- a/doc/pazpar2_protocol.xml +++ b/doc/pazpar2_protocol.xml @@ -273,8 +273,13 @@ search.pz?command=settings&session=2044502273&pz:allow[search.com:210/db1]=1 the number '0' (decreasing) or '1' (increasing). Default sort order is decreasing. Sort field names can be any field name designated as a sort field - in the pazpar2.cfg file, or the special names 'relevance' and - 'position'. + in the pazpar2.cfg file, or the special names 'relevance', + 'retrieval' and 'position'. + + + Sort type 'position' sorts by position/offset for each database. + Sort type 'retrieval' sorts by position of retrieval (first record + retrieved is 1, second record is 2, etc.). If not specified here or as @@ -287,7 +292,7 @@ search.pz?command=settings&session=2044502273&pz:allow[search.com:210/db1]=1 supports native sorting in order to get best results. Pazpar2 will trigger a new search if search criteria changes from Pazpar2 to target-based sorting or visa-versa. - + @@ -447,8 +452,13 @@ search.pz2?session=2044502273&command=stat the number '0' (decreasing) or '1' (increasing). Default sort order is decreasing. Sort field names can be any field name designated as a sort field - in the pazpar2.cfg file, or the special names 'relevance' and - 'position'. + in the pazpar2.cfg file, or the special names 'relevance', + 'retrieval' and 'position'. + + + Sort type 'position' sorts by position/offset for each database. + Sort type 'retrieval' sorts by position of retrieval (first record + retrieved is 1, second record is 2, etc.). If not specified here or as diff --git a/src/pazpar2_config.c b/src/pazpar2_config.c index e23c740..39aff41 100644 --- a/src/pazpar2_config.c +++ b/src/pazpar2_config.c @@ -1083,6 +1083,9 @@ static void info_service_metadata(struct conf_service *service, WRBUF w) case Metadata_type_position: wrbuf_puts(w, "position"); break; + case Metadata_type_retrieval: + wrbuf_puts(w, "retrieval"); + break; default: wrbuf_puts(w, "yes"); break; diff --git a/src/pazpar2_config.h b/src/pazpar2_config.h index 83d7314..5339e6c 100644 --- a/src/pazpar2_config.h +++ b/src/pazpar2_config.h @@ -38,6 +38,7 @@ enum conf_metadata_type { Metadata_type_skiparticle, Metadata_type_relevance, Metadata_type_position, + Metadata_type_retrieval, }; enum conf_metadata_merge { diff --git a/src/reclists.c b/src/reclists.c index 5afd057..245d061 100644 --- a/src/reclists.c +++ b/src/reclists.c @@ -123,6 +123,10 @@ struct reclist_sortparms *reclist_parse_sortparms(NMEM nmem, const char *parms, { type = Metadata_type_position; } + else if (!strcmp(parm, "retrieval")) + { + type = Metadata_type_retrieval; + } else { for (i = 0; i < service->num_sortkeys; i++) @@ -234,6 +238,9 @@ static int reclist_cmp(const void *p1, const void *p2) else res = 0; break; + case Metadata_type_retrieval: + res = r1->retrieval_position - r2->retrieval_position; + break; } if (res && !s->increasing) res *= -1; @@ -441,6 +448,7 @@ static struct record_cluster *new_cluster( cluster = nmem_malloc(l->nmem, sizeof(*cluster)); record->next = 0; + cluster->retrieval_position = l->num_records; cluster->records = record; cluster->merge_keys = 0; append_merge_keys(&cluster->merge_keys, merge_keys, l->nmem); diff --git a/src/record.c b/src/record.c index 84da2c8..19b06d7 100644 --- a/src/record.c +++ b/src/record.c @@ -129,6 +129,7 @@ int record_compare(struct record *r1, struct record *r2, return 0; case Metadata_type_position: case Metadata_type_relevance: + case Metadata_type_retrieval: break; } m1 = m1->next; diff --git a/src/record.h b/src/record.h index 0f1f249..95c470e 100644 --- a/src/record.h +++ b/src/record.h @@ -94,6 +94,7 @@ struct record_cluster float *term_frequency_vecf; // Set-specific ID for this record char *recid; + int retrieval_position; WRBUF relevance_explain1; WRBUF relevance_explain2; struct record *records; diff --git a/src/session.c b/src/session.c index 2862107..e67cd10 100644 --- a/src/session.c +++ b/src/session.c @@ -1547,6 +1547,7 @@ static struct record_metadata *record_metadata_init( break; case Metadata_type_relevance: case Metadata_type_position: + case Metadata_type_retrieval: return 0; } return rec_md; diff --git a/test/test_sort.urls b/test/test_sort.urls index bccdc0d..938b9f5 100644 --- a/test/test_sort.urls +++ b/test/test_sort.urls @@ -12,3 +12,4 @@ http://localhost:9763/search.pz2?session=2&command=init test_sort_settings.xml http://localhost:9763/search.pz2?session=2&command=settings http://localhost:9763/search.pz2?session=2&command=search&query=water http://localhost:9763/search.pz2?session=1&command=show&start=60&block=prefered&sort=date +http://localhost:9763/search.pz2?session=1&command=show&start=60&block=prefered&sort=retrieval:1 diff --git a/test/test_sort_15.res b/test/test_sort_15.res new file mode 100644 index 0000000..a369078 --- /dev/null +++ b/test/test_sort_15.res @@ -0,0 +1,368 @@ + +OK +0 +195 +1995 +60 +20 + + Potable water and methods of detecting impurities + 1899-1906 + Baker, M. N + book + + Potable water and methods of detecting impurities + 1899 + Baker, M. N + book + 1.7851623 + + + Potable water and methods of detecting impurities + 1906 + Baker, M. N + book + 1.7851623 + + 2 + content: title potable water and methods of detecting impurities author baker m n medium book + + + Water-analysis. A handbook for water-drinkers + 1882-1883 + Austin, George Lowell + book + + Water-analysis. A handbook for water-drinkers + 1882-1883 + Austin, George Lowell + book + 1.7851623 + + 1 + content: title water analysis a handbook for water drinkers author austin george lowell medium book + + + Report in relation to the water power on the line of the James River and Kanawha Canal + 1839 + Ellet, Charles + book + + Report in relation to the water power on the line of the James River and Kanawha Canal + 1839 + Ellet, Charles + book + 1.7851623 + + 1 + content: title report in relation to the water power on the line of the james river and kanawha canal author ellet charles medium book + + + A treatise on water-works for conveying and distributing supplies of water; + with tables and examples + 1835 + Storrow, Charles S + book + + A treatise on water-works for conveying and distributing supplies of water; + with tables and examples + 1835 + Storrow, Charles S + book + 1.7851623 + + 1 + content: title a treatise on water works for conveying and distributing supplies of water author storrow charles s medium book + + + An elementary handbook on potable water + 1891 + Davis, Floyd + book + + An elementary handbook on potable water + 1891 + Davis, Floyd + book + 1.7851623 + + 1 + content: title an elementary handbook on potable water author davis floyd medium book + + + Water-supply + (Considered principally from a sanitary standpoint.) + 1896 + Mason, William Pitt + book + + Water-supply + (Considered principally from a sanitary standpoint.) + 1896 + Mason, William Pitt + book + 1.7851623 + + 1 + content: title water supply author mason william pitt medium book + + + Water and public health + The relative purity of waters from different sources + 1897 + Fuertes, James Hillhouse + Microfilmed for preservationDNLM + book + + Water and public health + The relative purity of waters from different sources + 1897 + Fuertes, James Hillhouse + Microfilmed for preservationDNLM + book + 1.7851623 + + 1 + content: title water and public health author fuertes james hillhouse medium book + + + Water-quality assessment of part of the upper Mississippi River Basin, Minnesota and Wisconsin + design and implementation of water-quality studies, 1995-98 + 1999 + "National Water-Quality Assessment Program." + book + + Water-quality assessment of part of the upper Mississippi River Basin, Minnesota and Wisconsin + design and implementation of water-quality studies, 1995-98 + 1999 + "National Water-Quality Assessment Program." + book + 1.7284759 + + 1 + content: title water quality assessment of part of the upper mississippi river basin minnesota and wisconsin medium book + + + An empirical analysis of water temperature and dissolved oxygen conditions in the Red Deer River + 1997 + Saffran, Karen Anita + "March 1997." + book + + An empirical analysis of water temperature and dissolved oxygen conditions in the Red Deer River + 1997 + Saffran, Karen Anita + "March 1997." + book + 1.7284759 + + 1 + content: title an empirical analysis of water temperature and dissolved oxygen conditions in the red deer river author saffran karen anita medium book + + + Report of the Water Commissioners on the material best adapted for distribution water pipes + and on the most economical mode of introducing water in private houses + 1848 + Appendix contains reports by Eben N. Horsford and others + book + + Report of the Water Commissioners on the material best adapted for distribution water pipes + and on the most economical mode of introducing water in private houses + 1848 + Signed: Nathan Hale, Thomas B. Curtis + Issued as City document no. 32, 1848 + Appendix contains reports by Eben N. Horsford and others + book + 1.7284759 + + 1 + content: title report of the water commissioners on the material best adapted for distribution water pipes medium book + + + Boundary waters canoe camping + 2000 + Jacobson, Cliff + Rev. ed. of: Boundary waters. 1995 + book + + Boundary waters canoe camping + 2000 + Jacobson, Cliff + Rev. ed. of: Boundary waters. 1995 + book + 1.6871711 + + 1 + content: title boundary waters canoe camping author jacobson cliff medium book + + + Utah state water plan + Uintah Basin + 1999 + "December 1999." + book + + Utah state water plan + Uintah Basin + 1999 + "December 1999." + book + 1.6871711 + + 1 + content: title utah state water plan medium book + + + Water-quality trend analysis and sampling design for the Souris River, Saskatchewan, North Dakota, and Manitoba + 2000 + Vecchia, Aldo V + book + + Water-quality trend analysis and sampling design for the Souris River, Saskatchewan, North Dakota, and Manitoba + 2000 + Vecchia, Aldo V + book + 1.6871711 + + 1 + content: title water quality trend analysis and sampling design for the souris river saskatchewan north dakota and manitoba author vecchia aldo v medium book + + + Sharing the good + modes of managing water resources in the lower Mekong River Basin + 2000 + Öjendal, Joakim + Abstract (2 p.) inserted + book + + Sharing the good + modes of managing water resources in the lower Mekong River Basin + 2000 + Öjendal, Joakim + "March 2000." + Abstract (2 p.) inserted + book + 1.6871711 + + 1 + content: title sharing the good author o jendal joakim medium book + + + Mercados e instituciones de aguas en Bolivia + 1998 + book + + Mercados e instituciones de aguas en Bolivia + 1998 + book + 1.6871711 + + 1 + content: title mercados e instituciones de aguas en bolivia medium book + + + Water harvesting and supplemental irrigation for improved water use efficiency in dry areas + 1999 + Oweis, Theib Yousef + With reference to West Asia and North Africa + book + + Water harvesting and supplemental irrigation for improved water use efficiency in dry areas + 1999 + Oweis, Theib Yousef + With reference to West Asia and North Africa + book + 1.6871711 + + 1 + content: title water harvesting and supplemental irrigation for improved water use efficiency in dry areas author oweis theib yousef medium book + + + Water challenge and institutional response + a cross-country perspective + 1999 + Saleth, R. Maria + book + + Water challenge and institutional response + a cross-country perspective + 1999 + Saleth, R. Maria + book + 1.6871711 + + 1 + content: title water challenge and institutional response author saleth r maria medium book + + + Water and its purification; + a handbook for the use of local authorities, sanitary officers, and others interested in water supply; + 1902 + Rideal, Samuel + book + + Water and its purification; + a handbook for the use of local authorities, sanitary officers, and others interested in water supply; + 1902 + Rideal, Samuel + book + 1.6871711 + + 1 + content: title water and its purification author rideal samuel medium book + + + Schultz and Warker's mineral spring waters + their chemical composition, physiological action and therapeutical use; with a short review of the history of mineral waters + 1865 + Schultz, Carl H + book + + Schultz and Warker's mineral spring waters + their chemical composition, physiological action and therapeutical use; with a short review of the history of mineral waters + 1865 + Schultz, Carl H + book + 1.6871711 + + 1 + content: title schultz and warker s mineral spring waters author schultz carl h medium book + + + Report of the level two study for the Nine Mile Water and Sewer District + 1999 + Introduction -- Service planning area -- Land use planning -- Population and water usage -- Service system -- System design -- Permits, geotechnical issues, and surveying -- Cost estimate and financial analysis -- System operating plan -- References -- Plate 1 -- Appendices A-B + book + + Report of the level two study for the Nine Mile Water and Sewer District + 1999 + "November 1, 1999." + Introduction -- Service planning area -- Land use planning -- Population and water usage -- Service system -- System design -- Permits, geotechnical issues, and surveying -- Cost estimate and financial analysis -- System operating plan -- References -- Plate 1 -- Appendices A-B + book + 1.6423048 + + 1 + content: title report of the level two study for the nine mile water and sewer district medium book + + \ No newline at end of file