Changeset 31249

Show
Ignore:
Timestamp:
19.12.2016 14:37:31 (3 years ago)
Author:
kjdon
Message:

when doing highlightqueryterms we pass in the id of the document we are using. for solr, you can do a textquery with hldocID arg, and it will return the content of that section with the terms highlighted. when we do expand document, we need to use the section id we want, rather than the main d arg which is the same for each section

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/DocumentAction.java

    r30554 r31249  
    225225        if (document_type == null) 
    226226        { 
    227             logger.error("doctype is null!!!***********"); 
     227            logger.debug("doctype is null, setting to simple"); 
    228228            document_type = GSXML.DOC_TYPE_SIMPLE; 
    229229        } 
     
    310310        else 
    311311        { 
    312             // we dont need any structure 
     312          // we dont need any structure 
    313313        } 
    314314 
     
    526526            dc_request.appendChild(basic_doc_list); 
    527527        } 
    528         logger.debug("request = " + XMLConverter.getString(dc_message)); 
    529528        Element dc_response_message = (Element) this.mr.process(dc_message); 
    530529        if (processErrorElements(dc_response_message, page_response)) 
     
    532531            return result; 
    533532        } 
    534  
    535533        Element dc_response_doc_list = (Element) GSXML.getNodeByPath(dc_response_message, path); 
    536534 
     
    541539            for (int i = 0; i < doc_nodes.getLength(); i++) 
    542540            { 
    543                 Node content = GSXML.getChildByTagName((Element) dc_response_docs.item(i), "nodeContent"); 
     541                Node content = GSXML.getChildByTagName((Element) dc_response_docs.item(i), GSXML.NODE_CONTENT_ELEM); 
    544542                if (content != null) 
    545543                { 
    546544                    if (highlight_query_terms) 
    547545                    { 
    548                         content = highlightQueryTerms(request, (Element) content); 
     546                      String node_id = ((Element)doc_nodes.item(i)).getAttribute(GSXML.NODE_ID_ATT); 
     547                      content = highlightQueryTerms(request, node_id, (Element) content); 
    549548                    } 
     549                     
    550550                    doc_nodes.item(i).appendChild(doc.importNode(content, true)); 
    551551                } 
     
    597597                dc_response_doc.removeChild(dc_response_doc_content); 
    598598 
    599                 dc_response_doc_content = highlightQueryTerms(request, dc_response_doc_content); 
     599                dc_response_doc_content = highlightQueryTerms(request, null, dc_response_doc_content); 
    600600                dc_response_doc.appendChild(dc_response_doc.getOwnerDocument().importNode(dc_response_doc_content, true)); 
    601601            } 
     
    839839     * found in the text. 
    840840     */ 
    841     protected Element highlightQueryTerms(Element request, Element dc_response_doc_content) 
     841  protected Element highlightQueryTerms(Element request, String current_node_id, Element dc_response_doc_content) 
    842842    { 
    843843        Document doc = request.getOwnerDocument(); 
     
    871871        Element query_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
    872872        GSXML.addParametersToList(query_param_list, service_params); 
    873         GSXML.addParameterToList(query_param_list, "hldocOID", (String) params.get(GSParams.DOCUMENT)); 
     873        if (current_node_id != null) { 
     874          GSXML.addParameterToList(query_param_list, "hldocOID", current_node_id); 
     875        } else { 
     876          GSXML.addParameterToList(query_param_list, "hldocOID", (String) params.get(GSParams.DOCUMENT)); 
     877        } 
    874878        mr_query_request.appendChild(query_param_list); 
    875  
    876879        // do the query 
    877880        Element mr_query_response = (Element) this.mr.process(mr_query_message); 
    878                  
    879881        String pathNode = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.NODE_CONTENT_ELEM); 
    880882        Element highlighted_Node = (Element) GSXML.getNodeByPath(mr_query_response, pathNode); 
     883        // For SOLR, the above query may come back with a nodeContent element, which is the hldocOID section content, with search terms marked up. We send it back to the documnetContentRetrieve service so that resolveTextMacros can be applied, and it can be properly encased in documentNode etc elements 
    881884        if (highlighted_Node != null) 
    882885        { 
     
    900903            //Append highlighted content to request for processing 
    901904            dc_request.appendChild(doc.importNode(highlighted_Node, true)); 
    902                              
    903905            Element hl_response_message = (Element) this.mr.process(hl_message); 
     906         
    904907            //Get results 
    905908            NodeList contentList = hl_response_message.getElementsByTagName(GSXML.NODE_CONTENT_ELEM); 
     
    907910            return content; 
    908911        } 
    909  
    910912        String path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.TERM_ELEM + GSXML.LIST_MODIFIER); 
    911913        Element query_term_list_element = (Element) GSXML.getNodeByPath(mr_query_response, path);