Example usage for org.apache.solr.client.solrj.response QueryResponse getFacetField

List of usage examples for org.apache.solr.client.solrj.response QueryResponse getFacetField

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj.response QueryResponse getFacetField.

Prototype

public FacetField getFacetField(String name) 

Source Link

Document

get

Usage

From source file:argendata.service.impl.AppServiceImpl.java

@Override
public List<FacetCount> getIndexAllAppKeywords() {
    List<Count> resp = new ArrayList<Count>();

    QueryResponse rsp = null;

    String appQuery = "type:app";

    List<String> myFacetFields = new ArrayList<String>();
    List<String> myFiltersQuery = new ArrayList<String>();

    myFacetFields.add("appkeyword");

    try {//from   w  w  w  . j  av  a  2  s.  c o m
        rsp = solrDao.simpleFacetQuery(appQuery, 1, null, myFacetFields, myFiltersQuery, "title",
                SolrQuery.ORDER.asc);
    } catch (MalformedURLException e) {
        logger.fatal("No se puede conectar a solr");
    } catch (SolrServerException e) {
        logger.error(e.getMessage(), e);
    }

    if (rsp.getFacetField("appkeyword") != null) {
        List<Count> lc = rsp.getFacetField("appkeyword").getValues();
        if (lc != null)
            resp.addAll(lc);
    }
    return getFacetCount(resp);
}

From source file:argendata.service.impl.AppServiceImpl.java

private List<FacetCount> searchAppKeywords(String myTerms, List<String> mySortByFields, List<String> myKeywords)
        throws MalformedURLException, SolrServerException {

    List<Count> response = new ArrayList<Count>();

    QueryResponse queryRsp = searchQueryApp(myTerms, mySortByFields, myKeywords);

    if (queryRsp.getFacetField("appkeyword") != null) {
        List<Count> lc = queryRsp.getFacetField("appkeyword").getValues();
        if (lc != null)
            response.addAll(lc);// ww w.  ja v  a2 s  .  c o  m
    }

    return getFacetCount(response);
}

From source file:argendata.service.impl.DatasetServiceImpl.java

@Override
public List<Count> getAllIndexKeywords() throws MalformedURLException, SolrServerException {
    String[] kw = { "keyword" };
    QueryResponse resp = resolveIndexQuery("*", kw, null, null, null);

    return resp.getFacetField("keyword").getValues();
}

From source file:argendata.service.impl.DatasetServiceImpl.java

@Override
public List<Count> getAllIndexFormats() throws MalformedURLException, SolrServerException {
    String[] kw = { "format" };
    QueryResponse resp = resolveIndexQuery("*", kw, null, null, null);

    return resp.getFacetField("format").getValues();
}

From source file:argendata.service.impl.DatasetServiceImpl.java

@Override
public List<Count> getAllIndexPublishers() throws MalformedURLException, SolrServerException {
    String[] kw = { "publisher" };
    QueryResponse resp = resolveIndexQuery("*", kw, null, null, null);

    return resp.getFacetField("publisher").getValues();
}

From source file:argendata.service.impl.DatasetServiceImpl.java

@Override
public FacetDatasetResponse searchOnIndexFacetDataset(String terms, String[] queryFacetsFields,
        Map<String, String> filterValuesMap, List<String> mySortByFields, List<String> myKeywords) {
    QueryResponse rsp = null;
    try {/* w  w  w . jav  a  2 s .c  o  m*/
        rsp = resolveIndexQuery(terms, queryFacetsFields, filterValuesMap, mySortByFields, myKeywords);
    } catch (MalformedURLException e) {
        logger.fatal("No se puede conectar a solr");
    } catch (SolrServerException e) {
        logger.error(e.getMessage(), e);
    }

    List<Dataset> datasets = getDatasets(rsp);

    Map<String, List<FacetCount>> values = new HashMap<String, List<FacetCount>>();

    for (String a : queryFacetsFields) {
        List<FacetCount> fc = new ArrayList<FacetCount>();
        if (rsp.getFacetField(a).getValues() != null) {
            for (Count c : rsp.getFacetField(a).getValues()) {
                fc.add(new FacetCount(c.getName(), c.getCount()));
            }

            values.put(a, fc);
        }
    }

    return new FacetDatasetResponse(datasets, values);
}

From source file:argendata.service.impl.DatasetServiceImpl.java

@Override
public List<Count> getIndexAllLocations() throws MalformedURLException, SolrServerException {
    String[] kw = { "location" };
    QueryResponse resp = resolveIndexQuery("*", kw, null, null, null);

    return resp.getFacetField("location").getValues();
}

From source file:at.tugraz.kmi.medokyservice.rec.io.SolrDBClient.java

License:Open Source License

@SuppressWarnings("unchecked")
public Map<String, Long> getTagCountByUser(String username) throws SolrServerException {

    LinkedHashMap<String, Long> userTagCount = new LinkedHashMap<String, Long>();
    SolrQuery query = new SolrQuery("username:" + username).setFields(" ").setRows(1).setFacet(true)
            .setFacetMinCount(1).addFacetField("tags");

    QueryResponse rsp = this.query(query);
    FacetField ff = rsp.getFacetField("tags");

    for (Count count : ff.getValues()) {
        if (count.getName() == null || count.getName().length() <= 0)
            continue;

        userTagCount.put(count.getName(), count.getCount());
    }//  w  ww  . j  a va2  s .  co m

    return userTagCount;
}

From source file:at.tugraz.kmi.medokyservice.rec.io.SolrDBClient.java

License:Open Source License

public Map<String, Long> getTagCountByGroup(String courseId) throws SolrServerException {

    LinkedHashMap<String, Long> groupTags = new LinkedHashMap<String, Long>();

    SolrQuery query2 = new SolrQuery("course:" + courseId).setFields(" ").setRows(1).setFacet(true)
            .setFacetMinCount(1).addFacetField("tags");

    QueryResponse rsp2 = this.query(query2);

    FacetField ff = rsp2.getFacetField("tags");

    for (Count count : ff.getValues()) {
        if (count.getName() == null || count.getName().length() <= 0)
            continue;
        groupTags.put(count.getName(), count.getCount());
    }//w w  w  .  j a  v a2  s .c om

    return groupTags;
}

From source file:at.tugraz.kmi.medokyservice.rec.io.SolrDBClient.java

License:Open Source License

public Map<String, Long> getTagsByGroupOrUser(String groupId, String userId) throws SolrServerException {

    LinkedHashMap<String, Long> groupOrUserTags = new LinkedHashMap<String, Long>();

    SolrQuery query2 = new SolrQuery("course:" + groupId + " OR username:" + userId).setFields(" ").setRows(1)
            .setFacet(true).setFacetMinCount(1).addFacetField("tags");

    QueryResponse rsp2 = this.query(query2);

    FacetField ff = rsp2.getFacetField("tags");

    for (Count count : ff.getValues()) {
        if (count.getName() == null || count.getName().length() <= 0)
            continue;
        groupOrUserTags.put(count.getName(), count.getCount());
    }/*  ww w .j  a va  2 s.  c o m*/

    return groupOrUserTags;
}