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

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

Introduction

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

Prototype

public ModifiableSolrParams set(String name, String... val) 

Source Link

Document

Replace any existing parameter with the given name.

Usage

From source file:org.mousephenotype.cda.solr.service.ObservationService.java

License:Apache License

public List<Group> getDatapointsByColony(List<String> resourceName, String parameterStableId,
        String biologicalSampleGroup) throws SolrServerException, IOException {

    SolrQuery q = new SolrQuery();
    if (resourceName != null) {
        q.setQuery(ObservationDTO.DATASOURCE_NAME + ":"
                + StringUtils.join(resourceName, " OR " + ObservationDTO.DATASOURCE_NAME + ":"));
    } else {// w w  w. j  av  a  2s.  c o m
        q.setQuery("*:*");
    }

    if (parameterStableId != null) {
        q.addFilterQuery(ObservationDTO.PARAMETER_STABLE_ID + ":" + parameterStableId);
    }

    q.addFilterQuery(ObservationDTO.BIOLOGICAL_SAMPLE_GROUP + ":" + biologicalSampleGroup);

    q.set("group", true);
    q.set("group.field", ObservationDTO.COLONY_ID);
    q.set("group.limit", 10000);
    q.set("group.sort", ObservationDTO.DATE_OF_EXPERIMENT + " ASC");

    q.setFields(ObservationDTO.DATA_POINT, ObservationDTO.ZYGOSITY, ObservationDTO.SEX,
            ObservationDTO.DATE_OF_EXPERIMENT, ObservationDTO.ALLELE_SYMBOL, ObservationDTO.GENE_SYMBOL,
            ObservationDTO.COLONY_ID, ObservationDTO.ALLELE_ACCESSION_ID, ObservationDTO.PIPELINE_STABLE_ID,
            ObservationDTO.PHENOTYPING_CENTER, ObservationDTO.GENE_ACCESSION_ID,
            ObservationDTO.STRAIN_ACCESSION_ID, ObservationDTO.PARAMETER_STABLE_ID,
            ObservationDTO.PHENOTYPING_CENTER_ID);
    q.setRows(10000);

    logger.info("Solr url for getOverviewGenesWithMoreProceduresThan " + SolrUtils.getBaseURL(experimentCore)
            + "/select?" + q);
    return experimentCore.query(q).getGroupResponse().getValues().get(0).getValues();

}

From source file:org.mousephenotype.cda.solr.service.ObservationService.java

License:Apache License

public List<String> getGenesWithMoreProcedures(int n, List<String> resourceName)
        throws SolrServerException, IOException, InterruptedException, ExecutionException {

    List<String> genes = new ArrayList<>();
    SolrQuery q = new SolrQuery();

    if (resourceName != null) {
        q.setQuery(ObservationDTO.DATASOURCE_NAME + ":"
                + StringUtils.join(resourceName, " OR " + ObservationDTO.DATASOURCE_NAME + ":"));
    } else {/*w ww  .ja va  2s  . c om*/
        q.setQuery("*:*");
    }

    String geneProcedurePivot = ObservationDTO.GENE_SYMBOL + "," + ObservationDTO.PROCEDURE_NAME;

    q.add("facet.pivot", geneProcedurePivot);

    q.setFacet(true);
    q.setRows(1);
    q.setFacetMinCount(1);
    q.set("facet.limit", -1);

    logger.info("Solr url for getOverviewGenesWithMoreProceduresThan " + SolrUtils.getBaseURL(experimentCore)
            + "/select?" + q);
    QueryResponse response = experimentCore.query(q);

    for (PivotField pivot : response.getFacetPivot().get(geneProcedurePivot)) {
        if (pivot.getPivot() != null) {
            if (pivot.getPivot().size() >= n) {
                genes.add(pivot.getValue().toString());
            }
        }
    }

    return genes;
}

From source file:org.mousephenotype.cda.solr.service.ObservationService.java

License:Apache License

/**
 * Returns a map of categories, faceted by the given pivot, indexed by category, comprising # Genes and Gene Symbols
 *
 * @param resources/*w ww.  j  a va 2  s .co m*/
 * @param parameterStableIds A list of parameter_stable_id values (e.g. IMPC_VIA_001_001)
 * @param pivot              A comma-separated string of solr fields to pivot the facet by (e.g. category,gene_symbol)
 * @return a map of categories, faceted by the given pivot, indexed by category, comprising # Genes and Gene Symbols
 * @throws SolrServerException, IOException
 */
public List<Map<String, String>> getCategories(List<String> resources, List<String> parameterStableIds,
        String pivot) throws SolrServerException, IOException {

    SolrQuery query = new SolrQuery();

    if ((resources != null) && (!resources.isEmpty())) {
        query.setFilterQueries(ObservationDTO.DATASOURCE_NAME + ":"
                + StringUtils.join(resources, " OR " + ObservationDTO.DATASOURCE_NAME + ":"));
    }
    if ((parameterStableIds != null) && (!parameterStableIds.isEmpty())) {
        query.setQuery(ObservationDTO.PARAMETER_STABLE_ID + ":"
                + StringUtils.join(parameterStableIds, " OR " + ObservationDTO.PARAMETER_STABLE_ID + ":"));
    }
    query.setRows(0);
    query.setFacet(true);
    query.setFacetMinCount(1);
    query.setFacetLimit(-1);
    query.set("facet.pivot", pivot);

    logger.info("getCategories Url: " + SolrUtils.getBaseURL(experimentCore) + "/select?" + query);

    return getFacetPivotResults(experimentCore.query(query), false);
}

From source file:org.mousephenotype.cda.solr.service.ObservationService.java

License:Apache License

public Map<String, List<DiscreteTimePoint>> getTimeSeriesMutantData(String parameter, List<String> genes,
        List<String> strains, String[] center, String[] sex) throws SolrServerException, IOException {

    Map<String, List<DiscreteTimePoint>> finalRes = new HashMap<String, List<DiscreteTimePoint>>(); // <allele_accession,
    // timeSeriesData>

    SolrQuery query = new SolrQuery().addFilterQuery(ObservationDTO.BIOLOGICAL_SAMPLE_GROUP + ":experimental")
            .addFilterQuery(ObservationDTO.PARAMETER_STABLE_ID + ":" + parameter);

    String q = (strains.size() > 1) ? "(" + ObservationDTO.STRAIN_ACCESSION_ID + ":\""
            + StringUtils.join(strains.toArray(), "\" OR " + ObservationDTO.STRAIN_ACCESSION_ID + ":\"") + "\")"
            : ObservationDTO.STRAIN_ACCESSION_ID + ":\"" + strains.get(0) + "\"";

    if (genes != null && genes.size() > 0) {
        q += " AND (";
        q += (genes.size() > 1) ? ObservationDTO.GENE_ACCESSION_ID + ":\""
                + StringUtils.join(genes.toArray(), "\" OR " + ObservationDTO.GENE_ACCESSION_ID + ":\"") + "\""
                : ObservationDTO.GENE_ACCESSION_ID + ":\"" + genes.get(0) + "\"";
        q += ")";
    }/*from  ww w.  j a  va  2s  .  c  om*/

    if (center != null && center.length > 0) {
        q += " AND (";
        q += (center.length > 1)
                ? ObservationDTO.PHENOTYPING_CENTER + ":\""
                        + StringUtils.join(center, "\" OR " + ObservationDTO.PHENOTYPING_CENTER + ":\"") + "\""
                : ObservationDTO.PHENOTYPING_CENTER + ":\"" + center[0] + "\"";
        q += ")";
    }

    if (sex != null && sex.length == 1) {
        q += " AND " + ObservationDTO.SEX + ":\"" + sex[0] + "\"";
    }

    query.setQuery(q);
    query.set("group.field", ObservationDTO.GENE_SYMBOL);
    query.set("group", true);
    query.set("fl", ObservationDTO.DATA_POINT + "," + ObservationDTO.DISCRETE_POINT);
    query.set("group.limit", 100000); // number of documents to be returned
    // per group
    query.set("group.sort", ObservationDTO.DISCRETE_POINT + " asc");
    query.setRows(10000);

    // logger.info("+_+_+ " + SolrUtils.getBaseURL(experimentCore) + "/select?" +
    // query);
    List<Group> groups = experimentCore.query(query).getGroupResponse().getValues().get(0).getValues();
    // for mutants it doesn't seem we need binning
    // groups are the alleles
    for (Group gr : groups) {
        SolrDocumentList resDocs = gr.getResult();
        DescriptiveStatistics stats = new DescriptiveStatistics();
        float discreteTime = (float) resDocs.get(0).getFieldValue(ObservationDTO.DISCRETE_POINT);
        List<DiscreteTimePoint> res = new ArrayList<DiscreteTimePoint>();
        for (int i = 0; i < resDocs.getNumFound(); i++) {
            SolrDocument doc = resDocs.get(i);
            stats.addValue((float) doc.getFieldValue(ObservationDTO.DATA_POINT));
            if (discreteTime != (float) doc.getFieldValue(ObservationDTO.DISCRETE_POINT)
                    || i == resDocs.getNumFound() - 1) { // we
                // are
                // at
                // the
                // end
                // of
                // the
                // document
                // list
                // add to list
                float discreteDataPoint = (float) stats.getMean();
                DiscreteTimePoint dp = new DiscreteTimePoint(discreteTime, discreteDataPoint,
                        new Float(stats.getStandardDeviation()));
                List<Float> errorPair = new ArrayList<>();
                Float lower = new Float(discreteDataPoint);
                Float higher = new Float(discreteDataPoint);
                errorPair.add(lower);
                errorPair.add(higher);
                dp.setErrorPair(errorPair);
                res.add(dp);
                // update discrete point
                discreteTime = Float.valueOf(doc.getFieldValue(ObservationDTO.DISCRETE_POINT).toString());
                // update stats
                stats = new DescriptiveStatistics();
            }
        }
        // add list
        finalRes.put(gr.getGroupValue(), res);
    }
    return finalRes;
}

From source file:org.mousephenotype.cda.solr.service.ObservationService.java

License:Apache License

public List<DiscreteTimePoint> getTimeSeriesControlData(String parameter, List<String> strains, String[] center,
        String[] sex) throws SolrServerException, IOException {

    List<DiscreteTimePoint> res = new ArrayList<DiscreteTimePoint>();
    SolrQuery query = new SolrQuery().addFilterQuery(ObservationDTO.BIOLOGICAL_SAMPLE_GROUP + ":control")
            .addFilterQuery(ObservationDTO.PARAMETER_STABLE_ID + ":" + parameter);
    String q = (strains.size() > 1) ? "(" + ObservationDTO.STRAIN_ACCESSION_ID + ":\""
            + StringUtils.join(strains.toArray(), "\" OR " + ObservationDTO.STRAIN_ACCESSION_ID + ":\"") + "\")"
            : ObservationDTO.STRAIN_ACCESSION_ID + ":\"" + strains.get(0) + "\"";

    if (center != null && center.length > 0) {
        q += " AND (";
        q += (center.length > 1)// w  ww .j  ava 2 s .  co m
                ? ObservationDTO.PHENOTYPING_CENTER + ":\""
                        + StringUtils.join(center, "\" OR " + ObservationDTO.PHENOTYPING_CENTER + ":\"") + "\""
                : ObservationDTO.PHENOTYPING_CENTER + ":\"" + center[0] + "\"";
        q += ")";
    }

    if (sex != null && sex.length == 1) {
        q += " AND " + ObservationDTO.SEX + ":\"" + sex[0] + "\"";
    }

    query.setQuery(q);
    query.set("group.field", ObservationDTO.DISCRETE_POINT);
    query.set("group", true);
    query.set("fl", ObservationDTO.DATA_POINT + "," + ObservationDTO.DISCRETE_POINT);
    query.set("group.limit", 100000); // number of documents to be returned
    // per group
    query.set("sort", ObservationDTO.DISCRETE_POINT + " asc");
    query.setRows(10000);

    // logger.info("+_+_+ " + SolrUtils.getBaseURL(solr) + "/select?" +
    // query);
    List<Group> groups = experimentCore.query(query).getGroupResponse().getValues().get(0).getValues();
    boolean rounding = false;
    // decide if binning is needed i.e. is the increment points are too
    // scattered, as for calorimetry
    if (groups.size() > 30) { // arbitrary value, just piced it because it
        // seems reasonable for the size of our
        // graphs
        if (Float.valueOf(groups.get(groups.size() - 1).getGroupValue())
                - Float.valueOf(groups.get(0).getGroupValue()) <= 30) { // then
            // rounding
            // will
            // be
            // enough
            rounding = true;
        }
    }
    if (rounding) {
        int bin = Math.round(Float.valueOf(groups.get(0).getGroupValue()));
        for (Group gr : groups) {
            int discreteTime = Math.round(Float.valueOf(gr.getGroupValue()));
            // for calormetry ignore what's before -5 and after 16
            if (parameter.startsWith("IMPC_CAL") || parameter.startsWith("ESLIM_003_001")
                    || parameter.startsWith("M-G-P_003_001")) {
                if (discreteTime < -5) {
                    continue;
                } else if (discreteTime > 16) {
                    break;
                }
            }
            float sum = 0;
            SolrDocumentList resDocs = gr.getResult();
            DescriptiveStatistics stats = new DescriptiveStatistics();
            for (SolrDocument doc : resDocs) {
                sum += (float) doc.getFieldValue(ObservationDTO.DATA_POINT);
                stats.addValue((float) doc.getFieldValue(ObservationDTO.DATA_POINT));
            }
            if (bin < discreteTime || groups.indexOf(gr) == groups.size() - 1) { // finished
                // the
                // groups
                // of
                // filled
                // the
                // bin
                float discreteDataPoint = sum / resDocs.getNumFound();
                DiscreteTimePoint dp = new DiscreteTimePoint((float) discreteTime, discreteDataPoint,
                        new Float(stats.getStandardDeviation()));
                List<Float> errorPair = new ArrayList<>();
                double std = stats.getStandardDeviation();
                Float lower = new Float(discreteDataPoint - std);
                Float higher = new Float(discreteDataPoint + std);
                errorPair.add(lower);
                errorPair.add(higher);
                dp.setErrorPair(errorPair);
                res.add(dp);
                bin = discreteTime;
            }
        }
    } else {
        for (Group gr : groups) {
            Float discreteTime = Float.valueOf(gr.getGroupValue());
            float sum = 0;
            SolrDocumentList resDocs = gr.getResult();
            DescriptiveStatistics stats = new DescriptiveStatistics();
            for (SolrDocument doc : resDocs) {
                sum += (float) doc.getFieldValue(ObservationDTO.DATA_POINT);
                stats.addValue((float) doc.getFieldValue(ObservationDTO.DATA_POINT));
            }
            float discreteDataPoint = sum / resDocs.getNumFound();
            DiscreteTimePoint dp = new DiscreteTimePoint(discreteTime, discreteDataPoint,
                    new Float(stats.getStandardDeviation()));
            List<Float> errorPair = new ArrayList<>();
            double std = stats.getStandardDeviation();
            Float lower = new Float(discreteDataPoint - std);
            Float higher = new Float(discreteDataPoint + std);
            errorPair.add(lower);
            errorPair.add(higher);
            dp.setErrorPair(errorPair);
            res.add(dp);
        }
    }
    return res;
}

From source file:org.mousephenotype.cda.solr.service.ObservationService.java

License:Apache License

/**
 *
 * @param p//from   w  w w  .ja v  a 2 s. c o m
 * @param genes
 * @param strains
 * @param biologicalSample
 * @return list of centers and sexes for the given parameters
 * @throws SolrServerException, IOException
 */
public Set<String> getCenters(Parameter p, List<String> genes, List<String> strains, String biologicalSample)
        throws SolrServerException, IOException {

    Set<String> centers = new HashSet<String>();
    SolrQuery query = new SolrQuery()
            .addFilterQuery(ObservationDTO.BIOLOGICAL_SAMPLE_GROUP + ":" + biologicalSample)
            .addFilterQuery(ObservationDTO.PARAMETER_STABLE_ID + ":" + p.getStableId());
    String q = (strains.size() > 1) ? "(" + ObservationDTO.STRAIN_ACCESSION_ID + ":\""
            + StringUtils.join(strains.toArray(), "\" OR " + ObservationDTO.STRAIN_ACCESSION_ID + ":\"") + "\")"
            : ObservationDTO.STRAIN_ACCESSION_ID + ":\"" + strains.get(0) + "\"";
    String fq = "";
    if (genes != null && genes.size() > 0) {
        fq += " (";
        fq += (genes.size() > 1) ? ObservationDTO.GENE_ACCESSION_ID + ":\""
                + StringUtils.join(genes.toArray(), "\" OR " + ObservationDTO.GENE_ACCESSION_ID + ":\"") + "\""
                : ObservationDTO.GENE_ACCESSION_ID + ":\"" + genes.get(0) + "\"";
        fq += ")";
    }
    query.addFilterQuery(fq);
    query.setQuery(q);
    query.setRows(100000000);
    query.setFields(ObservationDTO.GENE_ACCESSION_ID, ObservationDTO.DATA_POINT);
    query.set("group", true);
    query.set("group.field", ObservationDTO.PHENOTYPING_CENTER);
    query.setSort(ObservationDTO.ID, SolrQuery.ORDER.asc);

    List<Group> groups = experimentCore.query(query, METHOD.POST).getGroupResponse().getValues().get(0)
            .getValues();
    for (Group gr : groups) {
        centers.add((String) gr.getGroupValue());
    }

    return centers;
}

From source file:org.mousephenotype.cda.solr.service.ObservationService.java

License:Apache License

public CategoricalSet getCategories(Parameter parameter, List<String> genes, String biologicalSampleGroup,
        List<String> strains, String[] center, String[] sex)
        throws SolrServerException, IOException, SQLException {

    CategoricalSet resSet = new CategoricalSet();
    resSet.setName(biologicalSampleGroup);
    SolrQuery query = new SolrQuery()
            .addFilterQuery(ObservationDTO.BIOLOGICAL_SAMPLE_GROUP + ":" + biologicalSampleGroup)
            .addFilterQuery(ObservationDTO.PARAMETER_STABLE_ID + ":" + parameter.getStableId());

    String q = (strains.size() > 1) ? "(" + ObservationDTO.STRAIN_ACCESSION_ID + ":\""
            + StringUtils.join(strains.toArray(), "\" OR " + ObservationDTO.STRAIN_ACCESSION_ID + ":\"") + "\")"
            : ObservationDTO.STRAIN_ACCESSION_ID + ":\"" + strains.get(0) + "\"";

    if (genes != null && genes.size() > 0) {
        q += " AND (";
        q += (genes.size() > 1) ? ObservationDTO.GENE_ACCESSION_ID + ":\""
                + StringUtils.join(genes.toArray(), "\" OR " + ObservationDTO.GENE_ACCESSION_ID + ":\"") + "\""
                : ObservationDTO.GENE_ACCESSION_ID + ":\"" + genes.get(0) + "\"";
        q += ")";
    }//from  w  w  w . jav a  2s . c  o m

    if (center != null && center.length > 0) {
        q += " AND (";
        q += (center.length > 1)
                ? ObservationDTO.PHENOTYPING_CENTER + ":\""
                        + StringUtils.join(center, "\" OR " + ObservationDTO.PHENOTYPING_CENTER + ":\"") + "\""
                : ObservationDTO.PHENOTYPING_CENTER + ":\"" + center[0] + "\"";
        q += ")";
    }

    if (sex != null && sex.length == 1) {
        q += " AND " + ObservationDTO.SEX + ":\"" + sex[0] + "\"";
    }

    query.setQuery(q);
    query.set("group.field", ObservationDTO.CATEGORY);
    query.set("group", true);
    query.setRows(100);
    query.setSort(ObservationDTO.ID, SolrQuery.ORDER.asc);

    logger.info("URL in getCategories " + SolrUtils.getBaseURL(experimentCore) + "/select?" + query);

    QueryResponse res = experimentCore.query(query, METHOD.POST);

    List<Group> groups = res.getGroupResponse().getValues().get(0).getValues();
    for (Group gr : groups) {
        CategoricalDataObject catObj = new CategoricalDataObject();
        catObj.setCount((long) gr.getResult().getNumFound());
        String catLabel = gr.getGroupValue();
        catObj.setCategory(catLabel);
        resSet.add(catObj);
    }
    return resSet;
}

From source file:org.mousephenotype.cda.solr.service.ObservationService.java

License:Apache License

/**
 * Returns a list of <code>count</code> parameter stable ids matching <code>observationType</code>.
 *
 * @param observationType desired observation type
 * @param count the number of parameter stable ids to return
 *
 * @return a list of <code>count</code> parameter stable ids matching <code>observationType</code>.
 * @throws SolrServerException, IOException
 *///from w  ww  .j av a  2s .c  om
public List<String> getParameterStableIdsByObservationType(ObservationType observationType, int count)
        throws SolrServerException, IOException {

    List<String> retVal = new ArrayList<String>();

    if (count < 1)
        return retVal;

    SolrQuery query = new SolrQuery();
    query.setQuery(ObservationDTO.OBSERVATION_TYPE + ":" + observationType.name())
            .addFacetField(ObservationDTO.PARAMETER_STABLE_ID).setFacetMinCount(1).setFacet(true).setRows(count)
            .setSort(ObservationDTO.ID, SolrQuery.ORDER.asc).set("facet.limit", count);

    QueryResponse response = experimentCore.query(query);
    for (Count facet : response.getFacetField(ObservationDTO.PARAMETER_STABLE_ID).getValues()) {
        retVal.add(facet.getName());
    }

    return retVal;
}

From source file:org.mousephenotype.cda.solr.service.ObservationService.java

License:Apache License

/**
 * @author tudose//w  ww.  j a v a2 s .  c  o  m
 * @date 2015/07/08
 * @param alleleAccession
 * @param phenotypingCenter
 * @param resource
 * @return List of pipelines with data for the given parameters.
 * @throws SolrServerException, IOException
 */
public List<ImpressBaseDTO> getPipelines(String alleleAccession, String phenotypingCenter,
        List<String> resource) throws SolrServerException, IOException {

    List<ImpressBaseDTO> pipelines = new ArrayList<>();

    SolrQuery query = new SolrQuery().setQuery("*:*")
            .addFilterQuery(ObservationDTO.ALLELE_ACCESSION_ID + ":\"" + alleleAccession + "\"")
            .addField(ObservationDTO.PIPELINE_ID).addField(ObservationDTO.PIPELINE_NAME)
            .addField(ObservationDTO.PIPELINE_STABLE_ID);
    if (phenotypingCenter != null) {
        query.addFilterQuery(ObservationDTO.PHENOTYPING_CENTER + ":\"" + phenotypingCenter + "\"");
    }
    if (resource != null) {
        query.addFilterQuery(ObservationDTO.DATASOURCE_NAME + ":\""
                + StringUtils.join(resource, "\" OR " + ObservationDTO.PHENOTYPING_CENTER + ":\"") + "\"");
    }

    query.set("group", true);
    query.set("group.field", ObservationDTO.PIPELINE_STABLE_ID);
    query.setRows(10000);
    query.setSort(ObservationDTO.ID, SolrQuery.ORDER.asc);
    query.set("group.limit", 1);

    logger.info("SOLR URL getPipelines " + SolrUtils.getBaseURL(experimentCore) + "/select?" + query);

    QueryResponse response = experimentCore.query(query);

    for (Group group : response.getGroupResponse().getValues().get(0).getValues()) {

        SolrDocument doc = group.getResult().get(0);
        ImpressBaseDTO pipeline = new ImpressBaseDTO();
        pipeline.setId(Long.getLong(doc.getFirstValue(ObservationDTO.PIPELINE_ID).toString()));
        pipeline.setStableId(doc.getFirstValue(ObservationDTO.PIPELINE_STABLE_ID).toString());
        pipeline.setName(doc.getFirstValue(ObservationDTO.PIPELINE_NAME).toString());
        pipelines.add(pipeline);

    }

    return pipelines;
}

From source file:org.mousephenotype.cda.solr.service.PhenotypeCenterService.java

License:Apache License

public List<PhenotypeCenterServiceBean> getMutantStrainsForCenter(String center)
        throws SolrServerException, IOException {

    List<PhenotypeCenterServiceBean> strains = new ArrayList<>();
    SolrQuery query = new SolrQuery()
            .setQuery(ObservationDTO.PHENOTYPING_CENTER + ":\"" + center + "\" AND "
                    + ObservationDTO.BIOLOGICAL_SAMPLE_GROUP + ":experimental")
            .setFields(ObservationDTO.GENE_ACCESSION_ID, ObservationDTO.ALLELE_SYMBOL,
                    ObservationDTO.GENE_SYMBOL, ObservationDTO.ZYGOSITY)
            .setRows(1000000);//from   w w  w. j  av  a  2  s  .  c  om
    query.set("group", true);
    query.set("group.field", ObservationDTO.COLONY_ID);
    query.set("group.limit", 1);

    if (SolrUtils.getBaseURL(experimentCore).endsWith("experiment")) {
        query.addFilterQuery(ObservationDTO.DATASOURCE_NAME + ":" + "\"" + datasourceName + "\"");
    }
    QueryResponse response = experimentCore.query(query);
    GroupResponse groups = response.getGroupResponse();
    for (Group group : groups.getValues().get(0).getValues()) {
        PhenotypeCenterServiceBean strain = new PhenotypeCenterServiceBean();
        String colonyId = group.getGroupValue();
        if (colonyId != null && !colonyId.equalsIgnoreCase("null")) {
            strain.setColonyId(colonyId);
            SolrDocument doc = group.getResult().get(0);
            strain.setAllele((String) doc.get(ObservationDTO.ALLELE_SYMBOL));
            strain.setGeneSymbol((String) doc.get(ObservationDTO.GENE_SYMBOL));
            strain.setMgiAccession((String) doc.get(ObservationDTO.GENE_ACCESSION_ID));
            strain.setZygosity((String) doc.get(ObservationDTO.ZYGOSITY));
            strains.add(strain);
        }
    }
    logger.info("getStrainsForCenter -- " + SolrUtils.getBaseURL(experimentCore) + "/select?" + query);
    return strains;
}