Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SearchHandle to expect search:extracted elements #262

Closed
sammefford opened this issue Feb 25, 2015 · 2 comments
Closed

Update SearchHandle to expect search:extracted elements #262

sammefford opened this issue Feb 25, 2015 · 2 comments

Comments

@sammefford
Copy link
Contributor

The REST API has added search:extracted elements when options include extract-document-data and the accept header is application/json or application/xml (not multipart/mixed). In this case we need the SearchHandle to be ready for the new elements.

@sammefford sammefford self-assigned this Feb 25, 2015
@sammefford sammefford added this to the 8.0-2 milestone Feb 25, 2015
@grechaw grechaw modified the milestones: 8.0-2, java-client-api-3.0.2 Feb 25, 2015
sammefford added a commit that referenced this issue May 7, 2015
…t for search:extracted and search:extracted-none elements
sammefford added a commit that referenced this issue May 7, 2015
…t for search:extracted and search:extracted-none elements
@sammefford sammefford added test and removed fix labels May 7, 2015
@sammefford sammefford assigned kkanthet and unassigned sammefford May 7, 2015
@sammefford
Copy link
Contributor Author

MatchDocumentSummary adds a new method:

public ExtractedResult getExtracted()

ExtractedResult is a new class:

public ExtractedResult {
    public boolean isExtractedNone();
    public Format getFormat();
    public String getContext();
    public String getKind();
    public int size();
}

ExtractedItem is a new class:

/** Access the extracted XML or JSON node using any AbstractReadHandle
 * or class registered by a ContentHandle. */
public interface ExtractedItem {
    public <T extends AbstractReadHandle> T get(T handle);
    public <T> T getAs(Class<T> as);
}

Example usage:

    String combinedSearch = 
      "<search:search xmlns:search=\"http://marklogic.com/appservices/search\">" +
        "<search:qtext>my search terms</search:qtext>" +
        "<search:options>" +
            "<search:extract-document-data>" +
                "<search:extract-path>/some/path</search:extract-path>" +
                "<search:extract-path>/another/path/*</search:extract-path>" +
            "</search:extract-document-data>" +
        "</search:options>" +
      "</search:search>";
    StringHandle queryHandle = new StringHandle(combinedSearch).withMimetype("application/xml");
    QueryDefinition query = queryMgr.newRawCombinedQueryDefinition(queryHandle);
    SearchHandle results = queryMgr.search(query, new SearchHandle());
    MatchDocumentSummary[] summaries = results.getMatchResults();
    for (MatchDocumentSummary summary : summaries) {
        ExtractedResult extracted = summary.getExtracted();
        if ( Format.XML == summary.getFormat() ) {
            for (ExtractedItem item : extracted) {
                Document extractItem = extracted.next().getAs(Document.class);
                ...
            }
        }
    }

sammefford added a commit that referenced this issue May 7, 2015
sammefford added a commit that referenced this issue May 7, 2015
sammefford added a commit that referenced this issue May 7, 2015
…tespace but the real test data doesn't have the whitespace
sammefford added a commit that referenced this issue May 7, 2015
…tespace but the real test data doesn't have the whitespace
@kcoleman-marklogic
Copy link
Contributor

I've updated the Java dev guide for this and will send it to you for review once I know it's working in the doc build, Sam.

kkanthet pushed a commit that referenced this issue May 20, 2015
@kkanthet kkanthet added ship and removed test labels May 20, 2015
@kkanthet kkanthet removed their assignment May 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants