List of usage examples for org.apache.solr.client.solrj SolrQuery setRows
public SolrQuery setRows(Integer rows)
From source file:dk.statsbiblioteket.doms.licensemodule.integrationtest.DomsSolrJClientTest.java
public static ArrayList<String> filterIds(ArrayList<String> ids, String queryPartAccess) throws Exception { solrServer.setRequestWriter(new BinaryRequestWriter()); //To avoid http error code 413/414, due to monster URI. (and it is faster) String queryPartStr = AbstractSolrJClient.makeAuthIdPart(ids); System.out.println(queryPartStr); SolrQuery query = new SolrQuery(queryPartStr); query.setFilterQueries(queryPartAccess); query.setFields("recordID"); query.set("facet", "false"); query.setRows(ids.size()); QueryResponse response = solrServer.query(query); ArrayList<String> filteredIds = AbstractSolrJClient.getIdsFromResponse(response); return filteredIds; }
From source file:dk.statsbiblioteket.doms.licensemodule.solr.AbstractSolrJClient.java
public ArrayList<String> filterIds(ArrayList<String> ids, String queryPartAccess) throws Exception { if (ids == null || ids.size() == 0) { return new ArrayList<String>(); }// w w w. j a v a 2 s . c o m String queryStr = makeAuthIdPart(ids); log.debug("query:" + queryStr); SolrQuery query = new SolrQuery(queryStr); query.setFilterQueries(queryPartAccess); log.debug("filter:" + queryPartAccess); query.setFields(filterField); //only this field is used from resultset query.setRows(Math.min(10000, ids.size() * 200)); // Powerrating... each page can have max 200 segments (rare).. with 20 pages query this is 4000.. query.set("facet", "false"); // Must be parameter set, because this java method does NOT work: query.setFacet(false); QueryResponse response = solrServer.query(query); ArrayList<String> filteredIds = getIdsFromResponse(response); return filteredIds; }
From source file:edu.cmu.lti.f12.hw2.hw2_team01.retrieval.SimpleSolrWrapper.java
License:Apache License
public SolrDocumentList runQuery(String q, int results) throws SolrServerException { SolrQuery query = new SolrQuery(); query.setQuery(escapeQuery(q));//from w w w . j a v a 2s . com query.setRows(results); query.setFields("*", "score"); System.out.println(query.toString()); QueryResponse rsp = server.query(query); return rsp.getResults(); }
From source file:edu.cmu.lti.f12.hw2.hw2_team01.retrieval.SimpleSolrWrapper.java
License:Apache License
public SolrDocumentList runQuery(String q, int results, String type, String mm, String Geneboost, String Diseboost, String Verbboost) throws SolrServerException { SolrQuery query = new SolrQuery(); if (type.equals("dismax")) { query.setParam("defType", "edismax"); query.setParam("qf", "text"); query.setParam("mm", mm); query.setParam("pf", "text^100"); }/* ww w . jav a 2 s. com*/ query.setQuery(getBoosts(escapeQuery(q), Geneboost, Diseboost, Verbboost)); query.setRows(results); query.setFields("*", "score"); //can also try nested query for different boosts of phrase in text //q=revised+AND+book+AND+_query_:"{!dismax qf=title pf=title^10 v=$qq}"&qq=revised+book System.out.println(query.toString()); QueryResponse rsp = server.query(query); return rsp.getResults(); }
From source file:edu.cmu.lti.f12.hw2.hw2_team01.retrieval.SimpleSolrWrapper.java
License:Apache License
public SolrDocumentList runQuery(String q, int results, String type, String Geneboost, String Diseboost, String Verbboost) throws SolrServerException { SolrQuery query = new SolrQuery(); if (type.equals("dismax")) { query.setParam("defType", "edismax"); query.setParam("qf", "text"); query.setParam("pf", "text^100"); }/* w w w . j ava 2s .co m*/ query.setQuery(getBoosts(escapeQuery(q), Geneboost, Diseboost, Verbboost)); query.setRows(results); query.setFields("*", "score"); //can also try nested query for different boosts of phrase in text //q=revised+AND+book+AND+_query_:"{!dismax qf=title pf=title^10 v=$qq}"&qq=revised+book System.out.println(query.toString()); QueryResponse rsp = server.query(query); return rsp.getResults(); }
From source file:edu.cmu.lti.oaqa.annographix.solr.SolrServerWrapper.java
License:Apache License
/** * Executes a string query./* w w w. j a v a2s . co m*/ * * @param q a query string. * @param numRet the maximum number of entries to return. * @return a list of documents, an object of the type {@link org.apache.solr.common.SolrDocumentList}. * @throws SolrServerException */ public SolrDocumentList runQuery(String q, int numRet) throws SolrServerException { SolrQuery query = new SolrQuery(); query.setQuery(q); query.setRows(numRet); query.setFields("*", "score"); QueryResponse rsp = mServer.query(query, METHOD.POST); return rsp.getResults(); }
From source file:edu.cmu.lti.oaqa.annographix.solr.SolrServerWrapper.java
License:Apache License
/** * Executes a query, additionally allows to specify result fields. * // w w w . j a v a 2 s. c o m * @param q a query string. * @param fieldList a list of field names. * @param results the maximum number of entries to return. * * @return a list of documents, which is an object of the type {@link org.apache.solr.common.SolrDocumentList}. * @throws SolrServerException */ public SolrDocumentList runQuery(String q, List<String> fieldList, int results) throws SolrServerException { SolrQuery query = new SolrQuery(); query.setQuery(q); query.setRows(results); query.setFields(fieldList.toArray(new String[1])); QueryResponse rsp = mServer.query(query, METHOD.POST); return rsp.getResults(); }
From source file:edu.cmu.lti.oaqa.annographix.solr.SolrServerWrapper.java
License:Apache License
/** * Executes a query, additionally allows to specify the default field, the filter query, AND result fields. * /*ww w . ja v a2 s .co m*/ * @param q a query string. * @param defaultField a default field name (or null). * @param fieldList a list of field names. * @param filterQuery a name of the filter query that can be applied without changing scores (or null). * @param results the maximum number of entries to return. * * @return a list of documents, which is an object of the type {@link org.apache.solr.common.SolrDocumentList}. * @throws SolrServerException */ public SolrDocumentList runQuery(String q, String defaultField, List<String> fieldList, String filterQuery, int results) throws SolrServerException { SolrQuery query = new SolrQuery(); query.setQuery(q); if (filterQuery != null) query.setParam("fq", filterQuery); if (defaultField != null) query.setParam("df", defaultField); query.setRows(results); query.setFields(fieldList.toArray(new String[1])); QueryResponse rsp = mServer.query(query, METHOD.POST); return rsp.getResults(); }
From source file:edu.cmu.lti.oaqa.bio.index.medline.annotated.query.SolrServerWrapper.java
License:Apache License
/** * Executes a string query./*from www .ja va2s. c o m*/ * * @param q a query string. * @param numRet the maximum number of entries to return. * @return a list of documents, an object of the type {@link org.apache.solr.common.SolrDocumentList}. * @throws SolrServerException * @throws IOException */ public SolrDocumentList runQuery(String q, int numRet) throws SolrServerException, IOException { SolrQuery query = new SolrQuery(); query.setQuery(q); query.setRows(numRet); query.setFields("*", "score"); QueryResponse rsp = mServer.query(query, METHOD.POST); return rsp.getResults(); }
From source file:edu.cmu.lti.oaqa.bio.index.medline.annotated.query.SolrServerWrapper.java
License:Apache License
/** * Executes a query, additionally allows to specify result fields. * //from w w w . java 2 s . co m * @param q a query string. * @param fieldList a list of field names. * @param results the maximum number of entries to return. * * @return a list of documents, which is an object of the type {@link org.apache.solr.common.SolrDocumentList}. * @throws SolrServerException * @throws IOException */ public SolrDocumentList runQuery(String q, List<String> fieldList, int results) throws SolrServerException, IOException { SolrQuery query = new SolrQuery(); query.setQuery(q); query.setRows(results); query.setFields(fieldList.toArray(new String[1])); QueryResponse rsp = mServer.query(query, METHOD.POST); return rsp.getResults(); }