|
36 | 36 | import com.marklogic.client.document.XMLDocumentManager; |
37 | 37 | import com.marklogic.client.io.DOMHandle; |
38 | 38 | import com.marklogic.client.io.Format; |
| 39 | +import com.marklogic.client.io.SearchHandle; |
39 | 40 | import com.marklogic.client.io.StringHandle; |
40 | 41 | import com.marklogic.client.query.KeyValueQueryDefinition; |
41 | 42 | import com.marklogic.client.query.QueryManager; |
@@ -156,4 +157,50 @@ private void runTransform(String transformName) |
156 | 157 |
|
157 | 158 | // TODO: QBE tests with XQuery and XSLT |
158 | 159 | } |
| 160 | + |
| 161 | + @Test |
| 162 | + public void test118() { |
| 163 | + String naiveTransform = "xquery version \"1.0-ml\";\n" + |
| 164 | + |
| 165 | + "module namespace ex = \"http://marklogic.com/rest-api/transform/test118\";\n" + |
| 166 | + |
| 167 | + "declare function ex:transform(\n" + |
| 168 | + " $context as map:map,\n" + |
| 169 | + " $params as map:map,\n" + |
| 170 | + " $content as document-node())\n" + |
| 171 | + "as document-node() {\n" + |
| 172 | + " document{\n" + |
| 173 | + |
| 174 | + "<search:response snippet-format=\"highlight\" total=\"1\" start=\"1\" page-length=\"1\" " + |
| 175 | + " xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"\" " + |
| 176 | + " xmlns:search=\"http://marklogic.com/appservices/search\">\n" + |
| 177 | + " <search:result index=\"1\" uri=\"/doc/2.xml\" path=\"fn:doc('/doc/2.xml')\" score=\"92160\" " + |
| 178 | + " confidence=\"0.674626\" fitness=\"0.674626\">\n" + |
| 179 | + " <search:snippet>\n" + |
| 180 | + " <headline>Q1 <match>outlook</match></headline>\n" + |
| 181 | + " </search:snippet>\n" + |
| 182 | + " <search:metadata>\n" + |
| 183 | + " <id>a</id>\n" + |
| 184 | + " </search:metadata>\n" + |
| 185 | + " </search:result>\n" + |
| 186 | + " <search:qtext>outlook snippet:highlight</search:qtext>\n" + |
| 187 | + " <search:metrics>\n" + |
| 188 | + " <search:query-resolution-time>PT0.008042S</search:query-resolution-time>\n" + |
| 189 | + " <search:facet-resolution-time>PT0.000323S</search:facet-resolution-time>\n" + |
| 190 | + " <search:snippet-resolution-time>PT0.018339S</search:snippet-resolution-time>\n" + |
| 191 | + " <search:total-time>PT0.027161S</search:total-time>\n" + |
| 192 | + " </search:metrics>\n" + |
| 193 | + "</search:response>}\n" + |
| 194 | + "};"; |
| 195 | + TransformExtensionsManager extensionMgr = |
| 196 | + Common.client.newServerConfigManager().newTransformExtensionsManager(); |
| 197 | + |
| 198 | + extensionMgr.writeXQueryTransform( "test118", new StringHandle().with(naiveTransform)); |
| 199 | + QueryManager q = Common.client.newQueryManager(); |
| 200 | + StringQueryDefinition s = q.newStringDefinition(""); |
| 201 | + s.setCriteria("a"); |
| 202 | + s.setResponseTransform(new ServerTransform("test118")); |
| 203 | + q.search(s, new SearchHandle()); |
| 204 | + // if the previous line throws no exception, then 118 is resolved |
| 205 | + } |
159 | 206 | } |
0 commit comments