Skip to content

Commit 7c558b5

Browse files
committed
fix #262 - oops, I forgot some files and left wire trace on in RawQueryDefinitionTest
1 parent 319c89b commit 7c558b5

File tree

3 files changed

+113
-1
lines changed

3 files changed

+113
-1
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2012-2015 MarkLogic Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.marklogic.client.query;
17+
18+
import com.marklogic.client.io.marker.StructureReadHandle;
19+
20+
/** Access the extracted XML or JSON node using any StructureReadHandle
21+
* or class registered by a ContentHandle. */
22+
public interface ExtractedItem {
23+
/** Get the item using the specified handle. */
24+
public <T extends StructureReadHandle> T get(T handle);
25+
/** Get the item using the handle registered for the specified class. */
26+
public <T> T getAs(Class<T> as);
27+
}
28+
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright 2012-2015 MarkLogic Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.marklogic.client.query;
17+
18+
import com.marklogic.client.io.Format;
19+
20+
/** Surfaces the data sent from the server-side XQuery search:search API. Note
21+
* that the most important function is to provide access to the list of ExtractedItem
22+
* objects. For example:
23+
* <pre> String combinedSearch =
24+
* "<search:search xmlns:search=\"http://marklogic.com/appservices/search\">" +
25+
* "<search:qtext>my search terms</search:qtext>" +
26+
* "<search:options>" +
27+
* "<search:extract-document-data>" +
28+
* "<search:extract-path>/some/path</search:extract-path>" +
29+
* "<search:extract-path>/another/path/*</search:extract-path>" +
30+
* "</search:extract-document-data>" +
31+
* "</search:options>" +
32+
* "</search:search>";
33+
* StringHandle queryHandle = new StringHandle(combinedSearch).withMimetype("application/xml");
34+
* QueryDefinition query = queryMgr.newRawCombinedQueryDefinition(queryHandle);
35+
* SearchHandle results = queryMgr.search(query, new SearchHandle());
36+
* MatchDocumentSummary[] summaries = results.getMatchResults();
37+
* for (MatchDocumentSummary summary : summaries) {
38+
* ExtractedResult extracted = summary.getExtracted();
39+
* if ( Format.XML == summary.getFormat() ) {
40+
* for (ExtractedItem item : extracted) {
41+
* Document extractItem = extracted.next().getAs(Document.class);
42+
* ...
43+
* }
44+
* }
45+
* }</pre>
46+
*
47+
* Where you can, of course, use any appropriate StructureReadHandle or corresponding
48+
* class (provided by that handle's receiveAs() method) passed to the
49+
* {@link ExtractedItem#getAs} method.
50+
**/
51+
public interface ExtractedResult extends Iterable<ExtractedItem> {
52+
53+
/** The format of the extracted data. Not always available, returns null if
54+
* unavailable. **/
55+
public Format getFormat();
56+
57+
/** The xquery to retrieve the parent document. Not always available, returns
58+
* null if unavailable. **/
59+
public String getContext();
60+
61+
/** The xquery type of the extracted data. For XML it will be "element". For
62+
* JSON it will be "object" or "array". Not always available, returns null if
63+
* unavailable. **/
64+
public String getKind();
65+
66+
/** Returns true if the underlying node is an "extracted-none" XML element or
67+
* JSON property. */
68+
public boolean isEmpty();
69+
70+
/** The number of ExtractedItem objects in the Iterator. */
71+
public int size();
72+
73+
/** Returns the next element in the internal iterator, which is separate
74+
* from any new iterator created by calls to iterator().
75+
* @return the next element in the iteration
76+
*/
77+
public ExtractedItem next();
78+
79+
/** Returns true if internal iterator has more elements.
80+
* The internal iterator is separate from any new iterator created by calls to iterator().
81+
* @return true if the internal iterator has more elements
82+
*/
83+
public boolean hasNext();
84+
}

src/test/java/com/marklogic/client/test/RawQueryDefinitionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public class RawQueryDefinitionTest {
7575
public static void beforeClass() {
7676
Common.connectAdmin();
7777
queryMgr = Common.client.newQueryManager();
78-
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.wire", "debug");
78+
//System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.wire", "debug");
7979
}
8080

8181
@AfterClass

0 commit comments

Comments
 (0)