Changeset 30057 for gs3-extensions/solr


Ignore:
Timestamp:
2015-07-25T07:27:52+12:00 (9 years ago)
Author:
Georgiy Litvinov
Message:

Solr repo fixes for highlighting bug.

Location:
gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/service/GS2SolrRetrieve.java

    r24641 r30057  
    2020
    2121import org.apache.log4j.Logger;
     22import org.greenstone.gsdl3.core.GSException;
     23import org.greenstone.gsdl3.util.GSXML;
     24import org.w3c.dom.Document;
     25import org.w3c.dom.Element;
     26import org.w3c.dom.Text;
    2227
    2328/** Does excatly the same as GS2LuceneRetrieve.  Wrap up in a bit of
     
    3742    super();
    3843    }
     44    @Override
     45    protected Element getNodeContent(Document doc, String doc_id, String lang) throws GSException
     46    {
     47     // IF we need only process our content by macro resolver
     48        if (highlightedNode != null)
     49        {
     50            String highlightedTextContent = highlightedNode.getTextContent();
     51           
     52            //Process text
     53            highlightedTextContent = resolveTextMacros(highlightedTextContent, doc_id, lang);
     54            //Create result element
     55            Element highlighted_node = doc.createElement(GSXML.NODE_CONTENT_ELEM);
     56            Text hlt = doc.createTextNode(highlightedTextContent);
     57            highlighted_node.appendChild(hlt);
     58            return highlighted_node;
     59        }
     60        return super.getNodeContent(doc, doc_id, lang);
     61   
     62    }
    3963}
    4064
  • gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/service/GS2SolrSearch.java

    r30050 r30057  
    348348            {
    349349                String rslt = this.solr_src.runHighlightingQuery(query,hldocOID);
     350                // Check result
     351                if (rslt != null)
     352                {
    350353                return rslt;
     354                }
     355                //Highlighting request failed. Do standard request.
     356                hldocOID = null;
    351357            }
    352358            SharedSoleneQueryResult sqr = this.solr_src.runQuery(query);
  • gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/util/SolrQueryWrapper.java

    r30050 r30057  
    559559            //Get highliting results
    560560            Map<String,Map<String,List<String>>> highlightingResults = solrResponse.getHighlighting();
    561             //Get highlited document text
    562             text = highlightingResults.get(hldocOID).get(highlight_field).get(0);
    563            
    564                                                
     561            // Check for existing highlighting results
     562            if (highlightingResults != null && highlightingResults.get(hldocOID) != null && highlightingResults.get(hldocOID).get(highlight_field) != null)
     563            {
     564                //Get highlited document text
     565                text = highlightingResults.get(hldocOID).get(highlight_field).get(0);
     566            }
    565567        }
    566568        catch (SolrServerException server_exception)
Note: See TracChangeset for help on using the changeset viewer.