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

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

Introduction

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

Prototype

public SolrQuery setRows(Integer rows) 

Source Link

Usage

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

License:Apache License

private QueryResponse getEmbryoLaczImageFacetsForGene(String mgiAccession, String parameterStableId,
        String... fields) throws SolrServerException, IOException {
    //solrQuery.addFilterQuery(ImageDTO.PARAMETER_STABLE_ID + ":IMPC_ELZ_064_001" + " OR "
    //+ ImageDTO.PARAMETER_STABLE_ID + ":IMPC_ELZ_063_001");
    // e.g.//from  w w w . j  a  v a 2s . c  o  m
    // http://ves-ebi-d0.ebi.ac.uk:8090/mi/impc/dev/solr/impc_images/select?q=gene_accession_id:%22MGI:1920455%22&facet=true&facet.field=selected_top_level_ma_term&fq=(parameter_name:%22LacZ%20Images%20Section%22%20OR%20parameter_name:%22LacZ%20Images%20Wholemount%22)
    // for embryo data the fields would be like this
    // "parameter_name": "LacZ images section",
    // "procedure_name": "Embryo LacZ",

    SolrQuery solrQuery = new SolrQuery();
    solrQuery.setQuery(ImageDTO.GENE_ACCESSION_ID + ":\"" + mgiAccession + "\"");
    solrQuery.addFilterQuery(ImageDTO.PARAMETER_STABLE_ID + ":" + parameterStableId);// reduce
    // the number to image parameters only as we are talking about images not expression data here
    solrQuery.setFacetMinCount(1);
    solrQuery.setFacet(true);
    solrQuery.setFields(fields);
    solrQuery.addFacetField(ImageDTO.SELECTED_TOP_LEVEL_ANATOMY_TERM);
    solrQuery.setRows(Integer.MAX_VALUE);
    solrQuery.setSort(ObservationDTO.ID, SolrQuery.ORDER.asc);
    QueryResponse response = impcImagesCore.query(solrQuery);
    return response;
}

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

License:Apache License

/**
 * Method that checks the impc images and categorical obeservations for expression data which is either expressed or not expressed.
 * @param anatomyId/*from   ww w  .  j  ava  2  s .co m*/
 * @return
 * @throws SolrServerException, IOException
 */
public boolean expressionDataAvailable(String anatomyId) throws SolrServerException, IOException {
    boolean expressionData = false;
    SolrQuery query = getBasicExpressionQuery(anatomyId);
    query.setRows(0);
    QueryResponse response = experimentCore.query(query);
    if (response.getResults().getNumFound() > 0) {
        expressionData = true;
    }

    //check the impc images core
    if (this.impcImagesHasExpression(anatomyId)) {
        expressionData = true;
    }
    return expressionData;
}

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

License:Apache License

/**
 * Return all genes in the gene core matching latestPhenotypeStatus and
 * latestProductionCentre.//from w  w  w. ja v  a 2  s.  c o  m
 * 
 * @param latestPhenotypeStatus
 *            latest phenotype status (i.e. most advanced along the pipeline)
 * @param latestProductionCentre
 *            latest production centre (i.e. most advanced along the pipeline)
 * @return all genes in the gene core matching phenotypeStatus and
 *         productionCentre.
 * @throws SolrServerException, IOException
 */
public Set<String> getGenesByLatestPhenotypeStatusAndProductionCentre(String latestPhenotypeStatus,
        String latestProductionCentre) throws SolrServerException, IOException {
    SolrQuery solrQuery = new SolrQuery();
    String queryString = "(" + GeneDTO.LATEST_PHENOTYPE_STATUS + ":\"" + latestPhenotypeStatus + "\") AND ("
            + GeneDTO.LATEST_PRODUCTION_CENTRE + ":\"" + latestProductionCentre + "\")";
    solrQuery.setQuery(queryString);
    solrQuery.setRows(1000000);
    solrQuery.setFields(GeneDTO.MGI_ACCESSION_ID);
    QueryResponse rsp = null;
    rsp = geneCore.query(solrQuery);
    SolrDocumentList res = rsp.getResults();
    HashSet<String> allGenes = new HashSet<String>();
    for (SolrDocument doc : res) {
        allGenes.add((String) doc.getFieldValue(GeneDTO.MGI_ACCESSION_ID));
    }

    log.debug("getGenesByLatestPhenotypeStatusAndProductionCentre: solrQuery = " + queryString);
    return allGenes;
}

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

License:Apache License

/**
 * Return all genes in the gene core matching latestPhenotypeStatus and
 * latestPhenotypeCentre.//from  w  ww  . j ava  2s  .  co m
 * 
 * @param latestPhenotypeStatus
 *            latest phenotype status (i.e. most advanced along the pipeline)
 * @param latestPhenotypeCentre
 *            latest phenotype centre (i.e. most advanced along the pipeline)
 * @return all genes in the gene core matching phenotypeStatus and
 *         productionCentre.
 * @throws SolrServerException, IOException
 */
public Set<String> getGenesByLatestPhenotypeStatusAndPhenotypeCentre(String latestPhenotypeStatus,
        String latestPhenotypeCentre) throws SolrServerException, IOException {

    SolrQuery solrQuery = new SolrQuery();
    String queryString = "(" + GeneDTO.LATEST_PHENOTYPE_STATUS + ":\"" + latestPhenotypeStatus + "\") AND ("
            + GeneDTO.LATEST_PHENOTYPING_CENTRE + ":\"" + latestPhenotypeCentre + "\")";
    solrQuery.setQuery(queryString);
    solrQuery.setRows(1000000);
    solrQuery.setFields(GeneDTO.MGI_ACCESSION_ID);
    QueryResponse rsp = null;
    rsp = geneCore.query(solrQuery);
    SolrDocumentList res = rsp.getResults();
    HashSet<String> allGenes = new HashSet<String>();
    for (SolrDocument doc : res) {
        allGenes.add((String) doc.getFieldValue(GeneDTO.MGI_ACCESSION_ID));
    }

    log.debug("getGenesByLatestPhenotypeStatusAndPhenotypeCentre: solrQuery = " + queryString);
    return allGenes;
}

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

License:Apache License

/**
 * Return all gene MGI IDs from the gene core.
 * //  w w w .  j a v  a  2  s  . c o m
 * @return all genes from the gene core.
 * @throws SolrServerException, IOException
 */
public Set<String> getAllGenes() throws SolrServerException, IOException {

    SolrQuery solrQuery = new SolrQuery();
    solrQuery.setQuery(GeneDTO.MGI_ACCESSION_ID + ":*");
    solrQuery.setRows(1000000);
    solrQuery.setFields(GeneDTO.MGI_ACCESSION_ID);
    QueryResponse rsp = null;
    rsp = geneCore.query(solrQuery);
    SolrDocumentList res = rsp.getResults();
    HashSet<String> allGenes = new HashSet<String>();
    for (SolrDocument doc : res) {
        allGenes.add((String) doc.getFieldValue(GeneDTO.MGI_ACCESSION_ID));
    }
    return allGenes;
}

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

License:Apache License

/**
 * Return all genes from the gene core.//from  w  w w  .  ja  v a  2  s.  com
 *
 * @return all genes from the gene core.
 * @throws SolrServerException, IOException
 */
public List<GeneDTO> getAllGeneDTOs() throws SolrServerException, IOException {

    SolrQuery solrQuery = new SolrQuery();
    solrQuery.setQuery("*:*");
    solrQuery.setRows(Integer.MAX_VALUE);
    return geneCore.query(solrQuery).getBeans(GeneDTO.class);
}

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

License:Apache License

/**
 * Return all genes from the gene core whose MGI_ACCESSION_ID does not start
 * with 'MGI'.//from w w w.  j  a  v a 2s . c o  m
 * 
 * @return all genes from the gene core whose MGI_ACCESSION_ID does not
 *         start with 'MGI'.
 * @throws SolrServerException, IOException
 */
public Set<String> getAllNonConformingGenes() throws SolrServerException, IOException {

    SolrQuery solrQuery = new SolrQuery();
    solrQuery.setQuery("-" + GeneDTO.MGI_ACCESSION_ID + ":MGI*");
    solrQuery.setRows(1000000);
    solrQuery.setFields(GeneDTO.MGI_ACCESSION_ID);
    QueryResponse rsp = null;
    rsp = geneCore.query(solrQuery);
    SolrDocumentList res = rsp.getResults();
    HashSet<String> allGenes = new HashSet<String>();

    for (SolrDocument doc : res) {
        allGenes.add((String) doc.getFieldValue(GeneDTO.MGI_ACCESSION_ID));
    }

    return allGenes;
}

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

License:Apache License

public List<GeneDTO> getGenesWithEmbryoViewer() throws SolrServerException, IOException {

    SolrQuery solrQuery = new SolrQuery();
    solrQuery.setQuery(GeneDTO.EMBRYO_DATA_AVAILABLE + ":true");
    solrQuery.setRows(1000000);
    solrQuery.setFields(GeneDTO.MGI_ACCESSION_ID, GeneDTO.MARKER_SYMBOL);

    return geneCore.query(solrQuery).getBeans(GeneDTO.class);

}

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

License:Apache License

/**
 * Get the mouse production status for gene (not allele) for geneHeatMap implementation for idg for each of 300 odd genes
 * @param geneIds//from w  w  w  .  j  av  a2 s  .  c  o m
 * @return Returns SolrDocument because that;s what the method to produce the status icons gets.
 * @throws SolrServerException, IOException
 */
public List<SolrDocument> getProductionStatusForGeneSet(Set<String> geneIds, Set<String> humanGeneSymbols)
        throws SolrServerException, IOException {

    SolrQuery solrQuery = new SolrQuery();
    solrQuery.setQuery("*:*");
    if (geneIds != null) {
        solrQuery.setFilterQueries(
                GeneDTO.MGI_ACCESSION_ID + ":(" + StringUtils.join(geneIds, " OR ").replace(":", "\\:") + ")");
    }
    if (humanGeneSymbols != null) {
        solrQuery.setFilterQueries(
                GeneDTO.HUMAN_GENE_SYMBOL + ":(" + StringUtils.join(humanGeneSymbols, " OR ") + ")");
    }
    solrQuery.setRows(Integer.MAX_VALUE);

    solrQuery.setFields(GeneDTO.MGI_ACCESSION_ID, GeneDTO.HUMAN_GENE_SYMBOL, GeneDTO.MARKER_SYMBOL,
            GeneDTO.ALLELE_NAME, GeneDTO.MOUSE_STATUS, GeneDTO.LATEST_ES_CELL_STATUS,
            GeneDTO.LATEST_PHENOTYPE_STATUS, GeneDTO.LEGACY_PHENOTYPE_STATUS, GeneDTO.HAS_QC,
            GeneDTO.TOP_LEVEL_MP_TERM);

    QueryResponse rsp = geneCore.query(solrQuery, METHOD.POST);

    return rsp.getResults();
}

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

License:Apache License

/**
 * Get the mouse top level mp associations for gene (not allele) for geneHeatMap implementation for idg for each of 300 odd genes
 * @param geneIds// ww w.j  a  v  a2  s . c  o m
 * @return
 * @throws SolrServerException, IOException
 */
public Map<String, List<String>> getTopLevelMpForGeneSet(Set<String> geneIds)
        throws SolrServerException, IOException {

    Map<String, List<String>> geneToStatusMap = new HashMap<>();
    SolrQuery solrQuery = new SolrQuery();
    String query = "*:*";
    solrQuery.setQuery(query);
    solrQuery.setFilterQueries(
            GeneDTO.MGI_ACCESSION_ID + ":(" + StringUtils.join(geneIds, " OR ").replace(":", "\\:") + ")");
    solrQuery.setRows(100000);
    solrQuery.setFields(GeneDTO.MGI_ACCESSION_ID, GeneDTO.TOP_LEVEL_MP_ID);

    QueryResponse rsp = geneCore.query(solrQuery, METHOD.POST);

    SolrDocumentList res = rsp.getResults();
    for (SolrDocument doc : res) {
        String accession = (String) doc.getFieldValue(GeneDTO.MGI_ACCESSION_ID);//each doc should have an accession
        List<String> topLevelMpIds = Collections.emptyList();
        if (doc.containsKey(GeneDTO.TOP_LEVEL_MP_ID)) {
            topLevelMpIds = getListFromCollection(doc.getFieldValues(GeneDTO.TOP_LEVEL_MP_ID));
        }

        geneToStatusMap.put(accession, topLevelMpIds);
    }
    return geneToStatusMap;
}