Changeset 32105


Ignore:
Timestamp:
2018-01-16T21:47:46+13:00 (4 years ago)
Author:
Georgiy Litvinov
Message:

Added docFilter query param for limiting results to document's sections.

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

Legend:

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

    r32086 r32105  
    251251        String physical_index_language_name = null;
    252252        String physical_sub_index_name = null;
     253        String docFilter = null;
    253254        int maxdocs = 100;
    254255        int hits_per_page = 20;
     
    339340                physical_index_language_name = value;
    340341            } // ignore any others
     342            else if (name.equals("docFilter"))
     343            {
     344                docFilter = value;
     345                docFilter = docFilter.replaceAll("[^A-Za-z0-9.]", "");
     346                    this.solr_src.setDocFilter(value);
     347            }
    341348        }
    342349        // set up start and end results if necessary
  • gs3-extensions/solr/trunk/src/src/java/org/greenstone/gsdl3/util/SolrQueryWrapper.java

    r31858 r32105  
    7373    protected int max_docs = 100;
    7474    protected String sort_order = SORT_DESCENDING;
     75    //Filter results by document hash. To get results from limited document sections.
     76    protected String docFilter = null;
    7577  protected String sort_field = SORT_BY_RANK; // don't want null default for solr
    7678    protected ArrayList<String> _facets = new ArrayList<String>();
     
    115117  {
    116118    this.sort_order = order;
     119  }
     120  public void setDocFilter(String docFilter)
     121  {
     122    this.docFilter = docFilter;
    117123  }
    118124    public void addFacet(String facet)
     
    356362        //TI:farming
    357363        //docOID,score,termfreq(TI,'farming'),totaltermfreq(TI,'farming')
    358 
     364       
    359365
    360366        // which fields to return for each document, we'll add the request for totaltermfreq later
     
    371377        solrQuery.setParam("hl.tag.post","&lt;/span&gt;" );
    372378       
     379        if (docFilter != null) {
     380            solrQuery.setParam("fq", "docOID:" + docFilter + "*");
     381        }
    373382        //solrQuery.setTerms(true); // turn on the termsComponent       
    374383        //solrQuery.set("terms.fl", "ZZ"); // which field to get the terms from. ModifiableSolrParams method
Note: See TracChangeset for help on using the changeset viewer.