From: Adam Dickmeiss Date: Tue, 2 Jun 2015 14:16:30 +0000 (+0200) Subject: bytarget includes native query PAZ-1005 X-Git-Tag: v1.10.0~3 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=6c1c46b74d3c184cec3254f07a1f11344d63337e;p=pazpar2-moved-to-github.git bytarget includes native query PAZ-1005 --- diff --git a/src/client.c b/src/client.c index 4e36630..e25bd2d 100644 --- a/src/client.c +++ b/src/client.c @@ -888,6 +888,22 @@ int client_parse_range(struct client *cl, const char *startrecs, return 0; } +const char *client_get_query(struct client *cl, const char **type, NMEM nmem) +{ + if (cl->pquery) + { + *type = "pqf"; + return nmem_strdup(nmem, cl->pquery); + } + if (cl->cqlquery) + { + *type = "cql"; + return nmem_strdup(nmem, cl->cqlquery); + } + *type = 0; + return 0; +} + int client_start_search(struct client *cl) { struct session_database *sdb = client_get_database(cl); diff --git a/src/client.h b/src/client.h index 8b427a7..a7866ba 100644 --- a/src/client.h +++ b/src/client.h @@ -116,6 +116,8 @@ void client_update_show_stat(struct client *cl, int cmd); void client_store_xdoc(struct client *cl, int record_no, xmlDoc *xdoc); +const char *client_get_query(struct client *cl, const char **type, NMEM nmem); + #endif /* diff --git a/src/http_command.c b/src/http_command.c index 7c23404..503f082 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -809,6 +809,15 @@ static void bytarget_response(struct http_channel *c, struct http_session *s, wrbuf_puts(c->wrbuf, ht[i].suggestions_xml); wrbuf_puts(c->wrbuf, ""); } + if (ht[i].query_data) + { + wrbuf_puts(c->wrbuf, ""); + wrbuf_xmlputs(c->wrbuf, ht[i].query_type); + wrbuf_puts(c->wrbuf, "\n"); + wrbuf_puts(c->wrbuf, ""); + wrbuf_xmlputs(c->wrbuf, ht[i].query_data); + wrbuf_puts(c->wrbuf, "\n"); + } wrbuf_puts(c->wrbuf, ""); } response_close(c, "bytarget"); diff --git a/src/session.c b/src/session.c index 9a68a22..2862107 100644 --- a/src/session.c +++ b/src/session.c @@ -1084,6 +1084,9 @@ static struct hitsbytarget *hitsbytarget_nb(struct session *se, wrbuf_rewind(w); res[*count].suggestions_xml = nmem_strdup(nmem, client_get_suggestions_xml(cl, w)); + + res[*count].query_data = + client_get_query(cl, &res[*count].query_type, nmem); wrbuf_destroy(w); (*count)++; } diff --git a/src/session.h b/src/session.h index f106c48..153c6ad 100644 --- a/src/session.h +++ b/src/session.h @@ -141,6 +141,8 @@ struct hitsbytarget { int connected; char *settings_xml; char *suggestions_xml; + const char *query_type; + const char *query_data; }; struct hitsbytarget *get_hitsbytarget(struct session *s, int *count, NMEM nmem); diff --git a/test/test_facets_10.res b/test/test_facets_10.res index 7bac2b5..787d057 100644 --- a/test/test_facets_10.res +++ b/test/test_facets_10.res @@ -7,4 +7,6 @@ 2 0 Client_Idle +pqf +@and 4 computer \ No newline at end of file diff --git a/test/test_facets_19.res b/test/test_facets_19.res index 1910a36..c2c7724 100644 --- a/test/test_facets_19.res +++ b/test/test_facets_19.res @@ -7,4 +7,6 @@ 2 0 Client_Idle +pqf +@and 6 computer \ No newline at end of file diff --git a/test/test_facets_5.res b/test/test_facets_5.res index ffc2e84..c830701 100644 --- a/test/test_facets_5.res +++ b/test/test_facets_5.res @@ -7,4 +7,6 @@ 7 0 Client_Idle +pqf +@and 7 computer \ No newline at end of file diff --git a/test/test_http_21.res b/test/test_http_21.res index 48290d2..c9b81cd 100644 --- a/test/test_http_21.res +++ b/test/test_http_21.res @@ -7,4 +7,6 @@ 0 0 Client_Idle +pqf +"kubiak stsław" \ No newline at end of file diff --git a/test/test_http_65.res b/test/test_http_65.res index bd79080..25910d0 100644 --- a/test/test_http_65.res +++ b/test/test_http_65.res @@ -7,4 +7,6 @@ 1 0 Client_Idle +pqf +@and @attr 1=1003 @attr 6=3 @or "adam, james" other_author @or @attr 1=1016 greece 2015 \ No newline at end of file diff --git a/test/test_http_71.res b/test/test_http_71.res index bd79080..25910d0 100644 --- a/test/test_http_71.res +++ b/test/test_http_71.res @@ -7,4 +7,6 @@ 1 0 Client_Idle +pqf +@and @attr 1=1003 @attr 6=3 @or "adam, james" other_author @or @attr 1=1016 greece 2015 \ No newline at end of file diff --git a/test/test_limit_limitmap_10.res b/test/test_limit_limitmap_10.res index 7aa85fa..8880233 100644 --- a/test/test_limit_limitmap_10.res +++ b/test/test_limit_limitmap_10.res @@ -7,6 +7,8 @@ 10 0 Client_Idle +pqf +@or @attr 1=1016 computer 2015 Target-2 LOC-SOLR @@ -15,4 +17,6 @@ 100 0 Client_Idle +pqf +@attr 4=Dal @attr 1=text computer \ No newline at end of file diff --git a/test/test_limit_limitmap_13.res b/test/test_limit_limitmap_13.res index 7aa85fa..8880233 100644 --- a/test/test_limit_limitmap_13.res +++ b/test/test_limit_limitmap_13.res @@ -7,6 +7,8 @@ 10 0 Client_Idle +pqf +@or @attr 1=1016 computer 2015 Target-2 LOC-SOLR @@ -15,4 +17,6 @@ 100 0 Client_Idle +pqf +@attr 4=Dal @attr 1=text computer \ No newline at end of file diff --git a/test/test_limit_limitmap_20.res b/test/test_limit_limitmap_20.res index 3802c69..aee0b85 100644 --- a/test/test_limit_limitmap_20.res +++ b/test/test_limit_limitmap_20.res @@ -7,4 +7,6 @@ 1 0 Client_Idle +pqf +@and @attr 1=1003 @attr 6=3 @or "adam, james" other_author @or @attr 1=1016 greece 2015 \ No newline at end of file diff --git a/test/test_limit_limitmap_5.res b/test/test_limit_limitmap_5.res index 72090aa..5e7f447 100644 --- a/test/test_limit_limitmap_5.res +++ b/test/test_limit_limitmap_5.res @@ -7,4 +7,6 @@ 1 2 Client_Idle +pqf +@and @or @and @attr 2=4 @attr 1=30 1976 @attr 2=2 @attr 1=30 1978 @attr 2=3 @attr 1=30 "date=\"foo#?" @or @attr 1=1016 computer 2015 \ No newline at end of file diff --git a/test/test_post_11.res b/test/test_post_11.res index f5a8e90..23bf77b 100644 --- a/test/test_post_11.res +++ b/test/test_post_11.res @@ -7,4 +7,6 @@ 10 0 Client_Idle +pqf +@or @attr 1=1016 computer 2015 \ No newline at end of file diff --git a/test/test_preferred.res b/test/test_preferred.res index 586b12e..e69de29 100644 --- a/test/test_preferred.res +++ b/test/test_preferred.res @@ -1,3 +0,0 @@ -connect.indexdata.com:9000/mit_opencourseware has preferred status: 1 -connect.indexdata.com:9000/mit_opencourseware has preferred status: 1 -connect.indexdata.com:9000/mit_opencourseware has preferred status: 1 diff --git a/test/test_preferred.sh b/test/test_preferred.sh deleted file mode 100755 index 493cdc3..0000000 --- a/test/test_preferred.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -TEST=`basename $0 .sh` -# srcdir might be set by make -srcdir=${srcdir:-"."} - -#TODO set up solr target. For now use donut - -${srcdir}/run_pazpar2.sh $TEST -E=$? - -grep "has preferred" ${TEST}pazpar2.log | cut -f 4- -d ' ' > test_preferred.log - -if [ -f test_preferred.res ] ; then - diff test_preferred.res test_preferred.log > test_preferred.dif - E2=$? - if [ $E2 -ne 0 ] ; then - echo "has preferred test failed!" - E=$E2 - fi -else - echo "Making test_preferred.res for first time." - mv test_preferred.log test_preferred.res -fi - -exit $E - -# Local Variables: -# mode:shell-script -# sh-indentation: 2 -# sh-basic-offset: 4 -# End: diff --git a/test/test_preferred_10.res b/test/test_preferred_10.res index 34d141b..5af687c 100644 --- a/test/test_preferred_10.res +++ b/test/test_preferred_10.res @@ -3,16 +3,22 @@ connect.indexdata.com:9000/mit_opencourseware MIT OpenCourseWare 0 -114 -(backend=localhost:9003) +2 +Temporary system error +Error: Value 'No query was entered' does not match regexp /.+\bdid not match any.+/ (backend=localhost:9003) 0 +0 Client_Error +pqf +@attr 1=21 computer ocs-loc.indexdata.com/solr/select LOC (SOLR) 0 -503 - +0 0 -Client_Error +0 +Client_Disconnected +pqf +@attr 1=subject computer \ No newline at end of file diff --git a/test/test_preferred_15.res b/test/test_preferred_15.res index 4c1b1f8..9f66842 100644 --- a/test/test_preferred_15.res +++ b/test/test_preferred_15.res @@ -3,24 +3,32 @@ connect.indexdata.com:9000/mit_opencourseware MIT OpenCourseWare 0 -114 -(backend=localhost:9003) +2 +Temporary system error +Error: Value 'No query was entered' does not match regexp /.+\bdid not match any.+/ (backend=localhost:9003) 0 +0 Client_Error +pqf +@attr 1=21 computer ocs-loc.indexdata.com/solr/select LOC (SOLR) 0 -503 - +0 0 -Client_Error +0 +Client_Working +pqf +@attr 1=subject computer ocs-oaister.indexdata.com/solr Oaister (SOLR) 0 -503 - +0 0 -Client_Error +0 +Client_Working +pqf +@attr 1=subject computer \ No newline at end of file diff --git a/test/test_preferred_5.res b/test/test_preferred_5.res index 44afb3f..def3cea 100644 --- a/test/test_preferred_5.res +++ b/test/test_preferred_5.res @@ -3,8 +3,12 @@ connect.indexdata.com:9000/mit_opencourseware MIT OpenCourseWare 0 -114 -(backend=localhost:9003) +2 +Temporary system error +Error: Value 'No query was entered' does not match regexp /.+\bdid not match any.+/ (backend=localhost:9003) 0 +0 Client_Error +pqf +@attr 1=21 computer \ No newline at end of file diff --git a/test/test_settings_7.res b/test/test_settings_7.res index cf7fcd5..e9bdd89 100644 --- a/test/test_settings_7.res +++ b/test/test_settings_7.res @@ -17,4 +17,6 @@ +pqf +@attr 1=host_wildcard water \ No newline at end of file diff --git a/test/test_settings_8.res b/test/test_settings_8.res index 63a213d..b4b60b6 100644 --- a/test/test_settings_8.res +++ b/test/test_settings_8.res @@ -13,4 +13,6 @@ +pqf +@attr 1=1016 water \ No newline at end of file diff --git a/test/test_solr_14.res b/test/test_solr_14.res index 313fc4a..ebd361c 100644 --- a/test/test_solr_14.res +++ b/test/test_solr_14.res @@ -7,4 +7,6 @@ 100 0 Client_Idle +pqf +@attr 4=Dal @attr 1=text water \ No newline at end of file diff --git a/test/test_solr_19.res b/test/test_solr_19.res index a47a5d4..888cad9 100644 --- a/test/test_solr_19.res +++ b/test/test_solr_19.res @@ -7,4 +7,6 @@ 200 0 Client_Idle +pqf +@attr 4=Dal @attr 1=text water \ No newline at end of file diff --git a/test/test_solr_26.res b/test/test_solr_26.res index 313fc4a..ebd361c 100644 --- a/test/test_solr_26.res +++ b/test/test_solr_26.res @@ -7,4 +7,6 @@ 100 0 Client_Idle +pqf +@attr 4=Dal @attr 1=text water \ No newline at end of file diff --git a/test/test_solr_5.res b/test/test_solr_5.res index 313fc4a..ebd361c 100644 --- a/test/test_solr_5.res +++ b/test/test_solr_5.res @@ -7,4 +7,6 @@ 100 0 Client_Idle +pqf +@attr 4=Dal @attr 1=text water \ No newline at end of file diff --git a/test/test_sort_5.res b/test/test_sort_5.res index a47a5d4..888cad9 100644 --- a/test/test_sort_5.res +++ b/test/test_sort_5.res @@ -7,4 +7,6 @@ 200 0 Client_Idle +pqf +@attr 4=Dal @attr 1=text water \ No newline at end of file diff --git a/test/test_termlist_block_10.res b/test/test_termlist_block_10.res index 3d39b01..034eb0c 100644 --- a/test/test_termlist_block_10.res +++ b/test/test_termlist_block_10.res @@ -7,6 +7,8 @@ 23 0 Client_Idle +pqf +computer id_solr LOC (SOLR) @@ -15,4 +17,6 @@ 100 0 Client_Idle +pqf +@attr 4=Dal @attr 1=text computer \ No newline at end of file diff --git a/test/test_termlist_block_13.res b/test/test_termlist_block_13.res index 3d39b01..034eb0c 100644 --- a/test/test_termlist_block_13.res +++ b/test/test_termlist_block_13.res @@ -7,6 +7,8 @@ 23 0 Client_Idle +pqf +computer id_solr LOC (SOLR) @@ -15,4 +17,6 @@ 100 0 Client_Idle +pqf +@attr 4=Dal @attr 1=text computer \ No newline at end of file diff --git a/test/test_termlist_block_5.res b/test/test_termlist_block_5.res index 9643e8a..4277135 100644 --- a/test/test_termlist_block_5.res +++ b/test/test_termlist_block_5.res @@ -7,4 +7,6 @@ 23 0 Client_Idle +pqf +computer \ No newline at end of file diff --git a/test/test_turbomarcxml_8.res b/test/test_turbomarcxml_8.res index 2df4e9a..24ce57a 100644 --- a/test/test_turbomarcxml_8.res +++ b/test/test_turbomarcxml_8.res @@ -7,4 +7,6 @@ 3 0 Client_Idle +pqf +computer \ No newline at end of file