From 1f966d166ff89011da3e8ca2fa143f017921ec57 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 5 May 2014 10:36:17 +0200 Subject: [PATCH] Solr: encode lucene query type YAZ-736 Make sure the queries are treated as traditional "lucene", because that's what YAZ generates. --- src/solr.c | 2 +- test/test_solr.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/solr.c b/src/solr.c index c1c1bba..e009908 100644 --- a/src/solr.c +++ b/src/solr.c @@ -494,7 +494,7 @@ int yaz_solr_encode_request(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, solr_op = "select"; if (!srw_pdu->u.request->query) return -1; - /* not considering query type here ! */ + yaz_add_name_value_str(encode, name, value, &i, "defType", "lucene"); yaz_add_name_value_str(encode, name, value, &i, "q", request->query); if (srw_pdu->u.request->startRecord) { diff --git a/test/test_solr.c b/test/test_solr.c index 9c30a5a..a2bfc06 100644 --- a/test/test_solr.c +++ b/test/test_solr.c @@ -69,7 +69,8 @@ void tst_encoding(void) sr->u.request->query = "title:solr"; YAZ_CHECK(compare_solr_req( odr, sr, 0, - "GET Default/select?q=title%3Asolr HTTP/1.1\r\n" + "GET Default/select?defType=lucene&q=title%3Asolr " + "HTTP/1.1\r\n" "User-Agent: YAZ/" YAZ_VERSION "\r\n" "Host: localhost\r\n" "Content-Type: text/xml\r\n\r\n")); @@ -81,7 +82,8 @@ void tst_encoding(void) sr->u.request->query = "title:solr"; YAZ_CHECK(compare_solr_req( odr, sr, "utf-8", - "GET Default/select?q=title%3Asolr HTTP/1.1\r\n" + "GET Default/select?defType=lucene&q=title%3Asolr " + "HTTP/1.1\r\n" "User-Agent: YAZ/" YAZ_VERSION "\r\n" "Host: localhost\r\n" "Content-Type: text/xml; charset=utf-8\r\n\r\n")); @@ -97,7 +99,8 @@ void tst_encoding(void) YAZ_CHECK(compare_solr_req( odr, sr, 0, - "GET Default/select?q=title%3Asolr&start=2&rows=10" + "GET Default/select?defType=lucene&q=title%3Asolr&" + "start=2&rows=10" " HTTP/1.1\r\n" "User-Agent: YAZ/" YAZ_VERSION "\r\n" "Host: localhost\r\n" @@ -116,7 +119,8 @@ void tst_encoding(void) YAZ_CHECK(compare_solr_req( odr, sr, 0, - "GET Default/select?q=title%3Asolr&start=2&rows=10" + "GET Default/select?defType=lucene&q=title%3Asolr&" + "start=2&rows=10" "&facet=true&facet.mincount=1&facet.field=date" "&facet.field=title_exact&f.title_exact.facet.limit=17" " HTTP/1.1\r\n" -- 1.7.10.4