Example usage for org.apache.solr.client.solrj SolrQuery setQuery

List of usage examples for org.apache.solr.client.solrj SolrQuery setQuery

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj SolrQuery setQuery.

Prototype

public SolrQuery setQuery(String query) 

Source Link

Usage

From source file:com.doculibre.constellio.stats.StatsSearcher.java

License:Open Source License

public QueryResponse getMostPopularQueriesZeroRes(String collectionName, SolrServer server, Date startDate,
        Date endDate, int start, int row) throws SolrServerException {
    SolrQuery solrQuery = new SolrQuery();
    solrQuery.setStart(start);/*from  ww w .  j  a v a  2 s.  co m*/
    solrQuery.setRows(row);
    solrQuery.setSort("freq", SolrQuery.ORDER.desc);
    StringBuffer querySB = new StringBuffer("collection:" + collectionName + " zero:true");
    //      querySB.append(" date:[");
    //      querySB.append(StatsCompiler.format(startDate));
    //      querySB.append(" TO ");
    //      querySB.append(StatsCompiler.format(endDate));
    //      querySB.append("]");
    solrQuery.setQuery(querySB.toString());
    return server.query(solrQuery);
}

From source file:com.doculibre.constellio.stats.StatsSearcher.java

License:Open Source License

public QueryResponse getMostPopularQueriesWithRes(String collectionName, SolrServer server, Date startDate,
        Date endDate, int start, int row) throws SolrServerException {
    SolrQuery solrQuery = new SolrQuery();
    solrQuery.setStart(start);//from ww  w . ja v a 2  s  .  c  o m
    solrQuery.setRows(row);
    solrQuery.setSort("freq", SolrQuery.ORDER.desc);
    StringBuffer querySB = new StringBuffer("collection:" + collectionName + " zero:false");
    //      querySB.append(" date:[");
    //      querySB.append(StatsCompiler.format(startDate));
    //      querySB.append(" TO ");
    //      querySB.append(StatsCompiler.format(endDate));
    //      querySB.append("]");
    solrQuery.setQuery(querySB.toString());
    return server.query(solrQuery);
}

From source file:com.doculibre.constellio.stats.StatsSearcher.java

License:Open Source License

public QueryResponse getMostPopularQueriesWithClick(String collectionName, SolrServer server, Date startDate,
        Date endDate, int start, int row) throws SolrServerException {
    SolrQuery solrQuery = new SolrQuery();
    solrQuery.setStart(start);//from  ww w  .jav  a  2s .com
    solrQuery.setRows(row);
    solrQuery.setSort("freq", SolrQuery.ORDER.desc);
    StringBuffer querySB = new StringBuffer("collection:" + collectionName + " clickstr:notzero");
    //      querySB.append(" date:[");
    //      querySB.append(StatsCompiler.format(startDate));
    //      querySB.append(" TO ");
    //      querySB.append(StatsCompiler.format(endDate));
    //      querySB.append("]");
    solrQuery.setQuery(querySB.toString());
    return server.query(solrQuery);
}

From source file:com.doculibre.constellio.stats.StatsSearcher.java

License:Open Source License

public QueryResponse getMostPopularQueriesWithoutClick(String collectionName, SolrServer server, Date startDate,
        Date endDate, int start, int row) throws SolrServerException {
    SolrQuery solrQuery = new SolrQuery();
    solrQuery.setStart(start);/* w ww .  j  av a  2  s .  c  om*/
    solrQuery.setRows(row);
    solrQuery.setSort("freq", SolrQuery.ORDER.desc);
    StringBuffer querySB = new StringBuffer("collection:" + collectionName + " clickstr:zero");
    //      querySB.append(" date:[");
    //      querySB.append(StatsCompiler.format(startDate));
    //      querySB.append(" TO ");
    //      querySB.append(StatsCompiler.format(endDate));
    //      querySB.append("]");
    solrQuery.setQuery(querySB.toString());
    return server.query(solrQuery);
}

From source file:com.doculibre.constellio.stats.StatsSearcher.java

License:Open Source License

public QueryResponse getQueryLog(String collectionName, SolrServer server, Date startDate, Date endDate,
        int start, int row) throws SolrServerException {
    SolrQuery solrQuery = new SolrQuery();
    solrQuery.setStart(start);/*from   w ww.j  a v  a  2 s.c o  m*/
    solrQuery.setRows(row);
    solrQuery.setSort("date", SolrQuery.ORDER.desc);
    StringBuffer querySB = new StringBuffer("collection:" + collectionName + " recherche:recherche");
    querySB.append(" date:[");
    querySB.append(StatsCompiler.format(startDate));
    querySB.append(" TO ");
    querySB.append(StatsCompiler.format(endDate));
    querySB.append("]");
    solrQuery.setQuery(querySB.toString());
    return server.query(solrQuery);
}

From source file:com.doculibre.constellio.stats.StatsSearcher.java

License:Open Source License

public QueryResponse getMostClickedDocsForQuery(String collectionName, String query, SolrServer server,
        int start, int row) throws SolrServerException {
    String escapedQuery = StatsCompiler.escape(query);
    SolrQuery solrQuery = new SolrQuery();
    solrQuery.setStart(start);/*from   w w w.j av a2 s  .  c o  m*/
    solrQuery.setRows(row);
    solrQuery.setSort("nbclick", SolrQuery.ORDER.desc);
    StringBuffer querySB = new StringBuffer(
            "collectionName:" + collectionName + " query:\"" + escapedQuery + "\"");
    solrQuery.setQuery(querySB.toString());
    return server.query(solrQuery);
}

From source file:com.doculibre.constellio.stats.StatsSearcher.java

License:Open Source License

public QueryResponse getMostClickedQueriesForURL(String collectionName, String url, SolrServer server,
        int start, int row) throws SolrServerException {
    SolrQuery solrQuery = new SolrQuery();
    solrQuery.setStart(start);//  ww w .ja v a 2  s .  c  o m
    solrQuery.setRows(row);
    solrQuery.setSort("nbclick", SolrQuery.ORDER.desc);
    StringBuffer querySB = new StringBuffer("collectionName:" + collectionName + " url:\"" + url + "\"");
    solrQuery.setQuery(querySB.toString());
    return server.query(solrQuery);
}

From source file:com.eharmony.matching.seeking.executor.solr.SolrQueryExecutor.java

License:Apache License

protected <T, R> SolrQuery translate(Query<T, R> query) {
    SolrQuery solrQuery = new SolrQuery();
    // special geospatial query case
    SolrSpatialQuery spatialQuery = queryTranslator.getSpatialQuery(query);
    String translated = queryTranslator.translate(query);
    solrQuery.setQuery(translated == null || translated.isEmpty() ? "*:*" : translated);
    if (spatialQuery != null) {
        //solrQuery.addFilterQuery("{!func}geodist()"); 
        solrQuery.addFilterQuery("{!geofilt}");
        solrQuery.set("sfield", spatialQuery.getField());
        solrQuery.set("pt", spatialQuery.getX() + "," + spatialQuery.getY());
        solrQuery.set("d", spatialQuery.getDistance().toString());
    }/*from   www.  j a  v a  2 s .c  o  m*/
    for (SolrOrdering ordering : queryTranslator.translateOrder(query).get()) {
        String field = ordering.getField();
        if (spatialQuery != null && field.equals(spatialQuery.getField())) {
            field = "geodist()";
        }
        solrQuery.addSortField(field, ordering.getOrder());
    }
    for (String field : queryTranslator.translateProjection(query)) {
        solrQuery.addField(field);
    }
    if (query.getMaxResults() != null) {
        solrQuery.setRows(query.getMaxResults());
    }
    return solrQuery;
}

From source file:com.gdn.x.ui.controller.CommonController.java

protected List searchByQuery(String queryParameter) throws MalformedURLException, SolrServerException {
    List actualResult = new ArrayList<String>();
    try {//from w w w . j av  a 2s.co  m
        //            for solr 5
        HttpSolrClient solr = new HttpSolrClient(solrUrlSearch);
        //for Solr 4
        //            HttpSolrServer solr = new HttpSolrServer("");

        SolrQuery query = new SolrQuery();

        query.setQuery(queryParameter);
        query.setFields("id");
        query.setRequestHandler("/browse");
        query.setStart(0);
        query.setRows(40);
        QueryResponse response = solr.query(query);
        SolrDocumentList results = response.getResults();

        int j = 0;
        for (int i = 0; i < results.size(); ++i, j++) {
            actualResult.add(results.get(i).get("id"));
        }
    } catch (IOException ex) {
        Logger.getLogger(RunGoldenListController.class.getName()).log(Level.SEVERE, null, ex);
    }

    return actualResult;
}

From source file:com.gdn.x.ui.controller.Evaluation.CommonControllerEvaluation.java

protected List searchByQueryEvaluation(String queryParameter)
        throws MalformedURLException, SolrServerException {
    List actualResult = new ArrayList<String>();
    try {/*w w  w . ja v a2 s.  c  o  m*/
        //            for solr 5
        HttpSolrClient solr = new HttpSolrClient(solrUrlSearch);
        //for Solr 4
        //            HttpSolrServer solr = new HttpSolrServer("http://172.17.132.9:8983/solr/collection3");

        SolrQuery query = new SolrQuery();

        query.setQuery(queryParameter);
        query.setFields("id");
        query.setRequestHandler("/browse");
        query.setStart(0);
        query.setRows(24);
        QueryResponse response = solr.query(query);
        SolrDocumentList results = response.getResults();

        int j = 0;
        for (int i = 0; i < results.size(); ++i, j++) {
            actualResult.add(results.get(i).get("id"));
        }
        //                System.out.println(results.getNumFound());
        //            System.out.println(actualResult);

    } catch (IOException ex) {
        Logger.getLogger(RunGoldenListController.class.getName()).log(Level.SEVERE, null, ex);
    }

    return actualResult;
}