359 |
#define _arg_node_uri 0 |
#define _arg_node_uri 0 |
360 |
#define _arg_login 1 |
#define _arg_login 1 |
361 |
#define _arg_passwd 2 |
#define _arg_passwd 2 |
362 |
#define _arg_query 3 |
#define _arg_depth 3 |
363 |
#define _arg_attr 4 |
#define _arg_query 4 |
364 |
#define _arg_order 5 |
#define _arg_attr 5 |
365 |
#define _arg_limit 6 |
#define _arg_order 6 |
366 |
#define _arg_offset 7 |
#define _arg_limit 7 |
367 |
#define _arg_attr_array 8 |
#define _arg_offset 8 |
368 |
|
#define _arg_attr_array 9 |
369 |
/* as (foo text, ... ); */ |
/* as (foo text, ... ); */ |
370 |
|
|
371 |
|
|
403 |
int resnum = 0; |
int resnum = 0; |
404 |
int limit = 0; |
int limit = 0; |
405 |
int offset = 0; |
int offset = 0; |
406 |
|
int depth = 0; |
407 |
|
|
408 |
char *node_url; |
char *node_url; |
409 |
char *user, *passwd; |
char *user, *passwd; |
481 |
user = _textout(PG_GETARG_TEXT_P(_arg_login)); |
user = _textout(PG_GETARG_TEXT_P(_arg_login)); |
482 |
passwd = _textout(PG_GETARG_TEXT_P(_arg_passwd)); |
passwd = _textout(PG_GETARG_TEXT_P(_arg_passwd)); |
483 |
|
|
484 |
|
/* depth of search */ |
485 |
|
if (PG_ARGISNULL(_arg_depth)) { |
486 |
|
depth = 0; |
487 |
|
} else { |
488 |
|
depth = PG_GETARG_INT32(_arg_depth); |
489 |
|
} |
490 |
|
|
491 |
/* query string */ |
/* query string */ |
492 |
if (PG_ARGISNULL(_arg_query)) { |
if (PG_ARGISNULL(_arg_query)) { |
493 |
query = ""; |
query = ""; |
535 |
node = est_node_new(node_url); |
node = est_node_new(node_url); |
536 |
est_node_set_auth(node, user, passwd); |
est_node_set_auth(node, user, passwd); |
537 |
|
|
538 |
elog(DEBUG1, "pgest_node: query[%s] attr[%s] limit %d offset %d", query, (PG_ARGISNULL(_arg_attr) ? "NULL" : attr), limit, offset); |
elog(DEBUG1, "pgest_node: node: %s (d:%d) query[%s] attr[%s] limit %d offset %d", node_url, depth, query, (PG_ARGISNULL(_arg_attr) ? "NULL" : attr), limit, offset); |
539 |
|
|
540 |
/* create a search condition object */ |
/* create a search condition object */ |
541 |
if (!(cond = est_cond_new())) { |
if (!(cond = est_cond_new())) { |
570 |
est_cond_set_max(cond, limit + offset); |
est_cond_set_max(cond, limit + offset); |
571 |
} |
} |
572 |
|
|
573 |
|
if (offset) { |
574 |
|
elog(DEBUG1,"est_cond_set_skip(%d)", offset); |
575 |
|
est_cond_set_skip(cond, offset); |
576 |
|
} |
577 |
|
|
578 |
/* get the result of search */ |
/* get the result of search */ |
579 |
/* FIXME: allow user to specify depath of search */ |
nres = est_node_search(node, cond, depth); |
|
nres = est_node_search(node, cond, 0); |
|
580 |
|
|
581 |
if (! nres) { |
if (! nres) { |
582 |
int status = est_node_status(node); |
int status = est_node_status(node); |
602 |
nrows = resnum - offset; |
nrows = resnum - offset; |
603 |
} |
} |
604 |
|
|
|
|
|
605 |
elog(DEBUG1, "pgest_node: found %d hits for %s", resnum, query); |
elog(DEBUG1, "pgest_node: found %d hits for %s", resnum, query); |
606 |
|
|
607 |
|
|
611 |
{ |
{ |
612 |
|
|
613 |
/* get result from estraier */ |
/* get result from estraier */ |
614 |
if (! ( rdoc = est_noderes_get_doc(nres, i + offset) )) { |
if (! ( rdoc = est_noderes_get_doc(nres, i) )) { |
615 |
elog(INFO, "pgest_node: can't find result %d", i + offset); |
elog(INFO, "pgest_node: can't find result %d", i + offset); |
616 |
} else { |
} else { |
617 |
elog(DEBUG1, "URI: %s\n Title: %s\n", |
elog(DEBUG1, "URI: %s\n Title: %s\n", |