-/* $Id: config.c,v 1.41 2007-09-10 16:25:50 adam Exp $
+/* $Id: config.c,v 1.42 2007-10-31 05:29:08 quinn Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
02111-1307, USA.
*/
-/* $Id: config.c,v 1.41 2007-09-10 16:25:50 adam Exp $ */
+/* $Id: config.c,v 1.42 2007-10-31 05:29:08 quinn Exp $ */
#include <string.h>
metadata->name = nmem_strdup(nmem, name);
- // enforcing that merge_range is always type_year
- if (merge == Metadata_merge_range)
- metadata->type = Metadata_type_year;
- else
- metadata->type = type;
+ metadata->type = type;
// enforcing that type_year is always range_merge
if (metadata->type == Metadata_type_year)
type = Metadata_type_generic;
else if (!strcmp((const char *) xml_type, "year"))
type = Metadata_type_year;
+ else if (!strcmp((const char *) xml_type, "date"))
+ type = Metadata_type_date;
else
{
yaz_log(YLOG_FATAL,
-/* $Id: config.h,v 1.27 2007-09-10 16:25:50 adam Exp $
+/* $Id: config.h,v 1.28 2007-10-31 05:29:08 quinn Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
enum conf_metadata_type {
Metadata_type_generic, // Generic text field
Metadata_type_number, // A number
- Metadata_type_year // A number
+ Metadata_type_year, // A number
+ Metadata_type_date // A number
};
enum conf_metadata_merge {
-/* $Id: logic.c,v 1.69 2007-10-02 12:11:14 adam Exp $
+/* $Id: logic.c,v 1.70 2007-10-31 05:29:08 quinn Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
rec_md->data.text.disp = nmem_strdup(nmem, p);
rec_md->data.text.sort = 0;
}
- else if (type == Metadata_type_year)
+ else if (type == Metadata_type_year || type == Metadata_type_date)
{
int first, last;
- if (extract7bit_years((char *) value, &first, &last) < 0)
+ int longdate = 0;
+
+ if (type == Metadata_type_date)
+ longdate = 1;
+ if (extract7bit_dates((char *) value, &first, &last, longdate) < 0)
return 0;
+
rec_md->data.number.min = first;
rec_md->data.number.max = last;
}
sizeof(union data_types));
prt = pp2_relevance_tokenize(
- global_parameters.server->sort_pct,
+ i global_parameters.server->sort_pct,
rec_md->data.text.disp);
pp2_relevance_token_next(prt);
-/* $Id: normalize7bit.c,v 1.4 2007-09-07 10:46:33 adam Exp $
+/* $Id: normalize7bit.c,v 1.5 2007-10-31 05:29:08 quinn Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
// Extract what appears to be years from buf, storing highest and
// lowest values.
-int extract7bit_years(const char *buf, int *first, int *last)
+// longdate==1, look for YYYYMMDD, longdate=0 look only for YYYY
+int extract7bit_dates(const char *buf, int *first, int *last, int longdate)
{
*first = -1;
*last = -1;
len = 0;
for (e = buf; *e && isdigit(*e); e++)
len++;
- if (len == 4)
+ if ((len == 4 && !longdate) || (longdate && len >= 4 && len <= 8))
{
int value = atoi(buf);
+ if (longdate && len == 4)
+ value *= 10000; // should really suffix 0101?
if (*first < 0 || value < *first)
*first = value;
if (*last < 0 || value > *last)
-/* $Id: normalize7bit.h,v 1.2 2007-04-27 12:17:04 marc Exp $
+/* $Id: normalize7bit.h,v 1.3 2007-10-31 05:29:08 quinn Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
char *normalize7bit_mergekey(char *buf, int skiparticle);
char * normalize7bit_generic(char * str, const char * rm_chars);
-int extract7bit_years(const char *buf, int *first, int *last);
+int extract7bit_dates(const char *buf, int *first, int *last, int longdate);
#endif