Solr: encode lucene query type YAZ-736
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 5 May 2014 08:36:17 +0000 (10:36 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 5 May 2014 08:36:17 +0000 (10:36 +0200)
Make sure the queries are treated as traditional "lucene", because that's
what YAZ generates.

src/solr.c
test/test_solr.c

index c1c1bba..e009908 100644 (file)
@@ -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)
         {
index 9c30a5a..a2bfc06 100644 (file)
@@ -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"