projects
/
yaz-moved-to-github.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
8cb8947
)
retrieval: pick matched element-set rule YAZ-813
author
Adam Dickmeiss
<adam@indexdata.dk>
Tue, 13 Jan 2015 12:55:52 +0000
(13:55 +0100)
committer
Adam Dickmeiss
<adam@indexdata.dk>
Tue, 13 Jan 2015 12:55:52 +0000
(13:55 +0100)
src/retrieval.c
patch
|
blob
|
history
diff --git
a/src/retrieval.c
b/src/retrieval.c
index
4c2920a
..
b65a3f3
100644
(file)
--- a/
src/retrieval.c
+++ b/
src/retrieval.c
@@
-297,6
+297,7
@@
int yaz_retrieval_request(yaz_retrieval_t p,
struct yaz_retrieval_elem *el = p->list;
int syntax_matches = 0;
int schema_matches = 0;
struct yaz_retrieval_elem *el = p->list;
int syntax_matches = 0;
int schema_matches = 0;
+ struct yaz_retrieval_elem *el_best = 0;
wrbuf_rewind(p->wr_error);
if (!el)
wrbuf_rewind(p->wr_error);
if (!el)
@@
-311,9
+312,9
@@
int yaz_retrieval_request(yaz_retrieval_t p,
else
{
if (el->name && yaz_match_glob(el->name, schema))
else
{
if (el->name && yaz_match_glob(el->name, schema))
- schema_ok = 1;
+ schema_ok = 2;
if (el->identifier && !strcmp(schema, el->identifier))
if (el->identifier && !strcmp(schema, el->identifier))
- schema_ok = 1;
+ schema_ok = 2;
if (!el->name && !el->identifier)
schema_ok = 1;
}
if (!el->name && !el->identifier)
schema_ok = 1;
}
@@
-329,34
+330,40
@@
int yaz_retrieval_request(yaz_retrieval_t p,
schema_matches++;
if (syntax_ok && schema_ok)
{
schema_matches++;
if (syntax_ok && schema_ok)
{
- *match_syntax = el->syntax;
- if (el->identifier)
- *match_schema = el->identifier;
- else
- *match_schema = 0;
- if (backend_schema)
- {
- if (el->backend_name)
- {
- if (*el->backend_name)
- *backend_schema = el->backend_name;
- }
- else if (el->name)
- *backend_schema = el->name;
- else
- *backend_schema = schema;
- }
- if (backend_syntax)
+ if (!el_best || schema_ok == 2)
+ el_best = el;
+ }
+ }
+ if (el_best)
+ {
+ el = el_best;
+ *match_syntax = el->syntax;
+ if (el->identifier)
+ *match_schema = el->identifier;
+ else
+ *match_schema = 0;
+ if (backend_schema)
+ {
+ if (el->backend_name)
{
{
- if (el->backend_syntax)
- *backend_syntax = el->backend_syntax;
- else
- *backend_syntax = el->syntax;
+ if (*el->backend_name)
+ *backend_schema = el->backend_name;
}
}
- if (rc)
- *rc = el->record_conv;
- return 0;
+ else if (el->name)
+ *backend_schema = el->name;
+ else
+ *backend_schema = schema;
}
}
+ if (backend_syntax)
+ {
+ if (el->backend_syntax)
+ *backend_syntax = el->backend_syntax;
+ else
+ *backend_syntax = el->syntax;
+ }
+ if (rc)
+ *rc = el->record_conv;
+ return 0;
}
if (!syntax_matches && syntax)
{
}
if (!syntax_matches && syntax)
{