Package org.apache.solr.client.solrj

Examples of org.apache.solr.client.solrj.SolrQuery


        for (ResearcherPage rp : rs)
        {
            boolean updated = false;
            int itemsCited = 0;
            int citations = 0;
            SolrQuery query = new SolrQuery();
            query.setQuery("dc.identifier.pmid:[* TO *]");
            query.addFilterQuery("{!field f=author_authority}"
                    + ResearcherPageUtils.getPersistentIdentifier(rp),"NOT(withdrawn:true)");
            query.setFields("dc.identifier.pmid");
            query.setRows(Integer.MAX_VALUE);

            QueryResponse response = searchService.search(query);
            SolrDocumentList results = response.getResults();
            for (SolrDocument doc : results)
            {
                Integer pmid = null;
                try
                {
                    pmid = Integer.valueOf((String) doc
                            .getFirstValue("dc.identifier.pmid"));
                }
                catch (NumberFormatException e)
                {
                    log.warn("Found invalid pmid: "
                            + doc.getFieldValue("dc.identifier.pmid")
                            + " for rp: "
                            + ResearcherPageUtils.getPersistentIdentifier(rp));
                }
                if (pmid != null)
                {
                    PMCCitation pmccitation = pmcService.get(PMCCitation.class,
                            pmid);
                    if (pmccitation != null && pmccitation.getNumCitations() > 0)
                    {
                        itemsCited++;
                        citations += pmccitation.getNumCitations();
                    }
                }
            }

            updated = setValue(applicationService, rp, itemsCitedTP,
                    String.valueOf(itemsCited));
            // caution don't use the short-circuit OR operator (i.e || otherwise
            // only the first found pmcdata value will be recorded!)
            updated = updated
                    | setValue(applicationService, rp, citationsTP,
                            String.valueOf(citations));
            updated = updated
                    | setValue(applicationService, rp, itemsInPubmedTP,
                            String.valueOf(results.getNumFound()));

            if (StringUtils.isNotEmpty(itemsInPMCTP))
            {
                query = new SolrQuery();
                query.setQuery("dc.identifier.pmcid:[* TO *]");
                query.addFilterQuery("{!field f=author_authority}"
                        + ResearcherPageUtils.getPersistentIdentifier(rp),"NOT(withdrawn:true)");
                query.setRows(0);

                response = searchService.search(query);
                results = response.getResults();
                // caution don't use the short-circuit OR operator (i.e || otherwise
                // only the first found pmcdata value will be recorded!)
View Full Code Here


    @Override
    public List<VisualizationGraphNode> load(List<String[]> discardedNode,
            Integer importedNodes, Boolean otherError) throws Exception
    {
        // load all publications
        SolrQuery solrQuery = new SolrQuery();
        solrQuery.setQuery(getQuery());
        solrQuery.addFacetField(getFacetFieldQuery());
        // solrQuery.addFilterQuery("authors_fauthority:rp00001");
        solrQuery.setFacetLimit(Integer.MAX_VALUE);
        solrQuery.setFacetMinCount(1);
        solrQuery.setRows(0);
        QueryResponse rsp = getService().getSearcher().search(solrQuery);
        FacetField facets = rsp.getFacetField(getFacetFieldQuery());
        System.out.println(facets.getValueCount());
        // for each interests get authority's authors
        List<VisualizationGraphNode> result = null;
View Full Code Here

            throws SearchServiceException
    {

        String query = "type:" + connection;

        SolrQuery solrQuery = new SolrQuery();
        solrQuery.setQuery(query);
        solrQuery.setStart(0);
        solrQuery.setRows(0);
        QueryResponse rsp = service.search(solrQuery);
        SolrDocumentList docs = rsp.getResults();
        if (docs != null)
        {
            if (docs.getNumFound() > 0)
View Full Code Here

    @Override
    public List<VisualizationGraphNode> load(List<String[]> discardedNode,
            Integer importedNodes, Boolean otherError) throws Exception
    {
        // load all publications
        SolrQuery solrQuery = new SolrQuery();
        solrQuery.setQuery(getQuery());
        solrQuery.addFacetField(getFacetFieldQuery());
        // solrQuery.addFilterQuery("authors_fauthority:rp00001");
        solrQuery.setFacetLimit(Integer.MAX_VALUE);
        solrQuery.setFacetMinCount(1);
        solrQuery.setRows(0);
        QueryResponse rsp = getService().getSearcher().search(solrQuery);
        FacetField facets = rsp.getFacetField(getFacetFieldQuery());
        System.out.println(facets.getValueCount());
        // for each interests get authority's authors
        List<VisualizationGraphNode> result = null;
        int counter = 0;
        external: for (Count facetElement : facets.getValues())
        {
            counter++;

            log.debug(getConnectionName() + " - " + counter + " of "
                    + facets.getValueCount());
            System.out.println(getConnectionName() + " - " + counter + " of "
                    + facets.getValueCount());
            result = new LinkedList<VisualizationGraphNode>();
            try
            {

                String facetValue = facetElement.getName();

                solrQuery = new SolrQuery();
                String query = (useJoin()?getJoin():"") + getFacetFieldQuery() + ":\"" + ClientUtils.escapeQueryChars(facetValue) + "\"";
                solrQuery.setQuery(query);
                solrQuery.addFacetField(getFacet(facetValue));
                solrQuery.setFacetMinCount(1);
                solrQuery.setFacetLimit(getFacetLimit());
                solrQuery.setRows(0);

                rsp = getService().getSearcher().search(solrQuery);
                FacetField relations = rsp.getFacetField(getFacet(facetValue));
                int i = 0;
                internal: for (Count relation : relations.getValues())
View Full Code Here

    public JsGraph search(String authority, String name, Integer level,
            boolean showExternal, boolean showSameDept, String dept,
            Integer modeEntity) throws Exception
    {

        SolrQuery solrQuery = new SolrQuery();

        String query = buildQuery(authority, name, showSameDept, dept,
                modeEntity, level);
        String[] fqs = {"type:" + getConnectionName(), "entity:" + modeEntity};
        solrQuery.setQuery(query);
        solrQuery.addFilterQuery(fqs);
  if (!showExternal && authority != null && !authority.isEmpty()) {
    solrQuery.addFilterQuery(new String[] {"a_auth:rp*", "b_auth:rp*" });
  }
        solrQuery.setFacet(true);
        solrQuery.addFacetField(FACET_SEARCH);
        if (modeEntity == ConstantNetwork.ENTITY_RP)
        {
            solrQuery.setFacetLimit(getLimitLevel(level));
        }
        else if (modeEntity == ConstantNetwork.ENTITY_DEPT)
        {
            solrQuery.setFacetLimit(Integer.MAX_VALUE);
        }
        solrQuery.setFacetMinCount(1);
        solrQuery.setRows(0);

        QueryResponse rsp = service.search(solrQuery);

        FacetField facets = rsp.getFacetField(FACET_SEARCH);

View Full Code Here

    public List<ResearcherPage> loadMetrics(List<String[]> discardedNode,
            Integer importedNodes, Boolean otherError)
            throws SearchServiceException
    {
        // load all publications
        SolrQuery solrQuery = new SolrQuery();
        solrQuery.setQuery("type:" + getType() + " AND entity:"
                + ConstantNetwork.ENTITY_RP);
        solrQuery.addFacetField(FACET_METRICS);
        solrQuery.setFacetLimit(Integer.MAX_VALUE);
        solrQuery.setFacetMinCount(1);
        solrQuery.setRows(0);
        QueryResponse rsp = getService().search(solrQuery);
        FacetField facets = rsp.getFacetField(FACET_METRICS);

        // for each interests get authority's authors
        List<ResearcherPage> result = new LinkedList<ResearcherPage>();
        int counter = 0;
        external: for (Count facetElement : facets.getValues())
        {
            counter++;
            log.debug("" + counter + " of " + facets.getValueCount());
            ResearcherPage researcher = null;
            try
            {
                String facetValue = facetElement.getName();

                Integer realPersistentIdentifier = ResearcherPageUtils
                        .getRealPersistentIdentifier(facetValue, ResearcherPage.class);
                researcher = applicationService
                        .get(ResearcherPage.class, realPersistentIdentifier);
                //researcher.getDynamicField().setAnagraficaLazy(applicationService.getAnagraficaByRP(realPersistentIdentifier));
           
                solrQuery = new SolrQuery();
                solrQuery.setQuery("type:" + getType() + " AND entity:" + ConstantNetwork.ENTITY_RP + " AND " + FACET_METRICS + ":\"" + facetValue + "\"");
                solrQuery.addFacetField(FACET_SEARCH);
                solrQuery.setFacetMinCount(1);
                solrQuery.setFacetLimit(Integer.MAX_VALUE);
                solrQuery.setRows(0);

                rsp = getService().search(solrQuery);
                FacetField relations = rsp.getFacetField(FACET_SEARCH);
                int i = 0;
                int nConnections = 0;
View Full Code Here

        nConnectionRPP.setVisibility(VisibilityConstants.PUBLIC);
    }
   
    protected String getDepartmentFromSOLR(String a_authority) throws SearchServiceException
    {
        SolrQuery solrQuery = new SolrQuery();
        solrQuery.setQuery("search.resourceid:" +ResearcherPageUtils
                .getRealPersistentIdentifier(a_authority, ResearcherPage.class) + " AND search.resourcetype:" + CrisConstants.RP_TYPE_ID);
        solrQuery.setFields("rp_dept");       
        solrQuery.setRows(1);
        QueryResponse rsp = getService().getSearcher().search(solrQuery);
        SolrDocumentList publications = rsp.getResults();
       
        Iterator<SolrDocument> iter = publications.iterator();
View Full Code Here

        return rp_dept;
    }

    protected String getStatusFromSOLR(String a_authority) throws SearchServiceException
    {
        SolrQuery solrQuery = new SolrQuery();
        solrQuery.setQuery("search.resourceid:" +ResearcherPageUtils
                .getRealPersistentIdentifier(a_authority, ResearcherPage.class) + " AND search.resourcetype:" + CrisConstants.RP_TYPE_ID);
        solrQuery.setFields("rp_boolean_status");       
        solrQuery.setRows(1);
        QueryResponse rsp = getService().getSearcher().search(solrQuery);
        SolrDocumentList publications = rsp.getResults();
       
        Iterator<SolrDocument> iter = publications.iterator();
View Full Code Here

     * @throws IOException If errors found
     */
    private QueryResponse runQuery(String query, int start, int rows,
            String fields, String filter, String[] facets, int facetLimit)
            throws Exception {
        SolrQuery q = new SolrQuery();
        q.setQuery(query);
        q.setStart(start);
        q.setRows(rows);
        q.setFields(fields);
        if (filter != null) {
            q.setFilterQueries(filter);
        }
        if (facets != null) {
            q.setFacet(true);
            q.setFacetLimit(facetLimit);
            q.addFacetField(facets);
        } else {
            q.setFacet(false);
        }
        return solrServer.query(q);
    }
View Full Code Here

    /** Return each index as a split. */
    public InputSplit[] getSplits(JobConf job, int numSplits) throws IOException {
      SolrServer solr = new CommonsHttpSolrServer(job.get(SolrConstants.SERVER_URL));

      final SolrQuery solrQuery = new SolrQuery(SOLR_GET_ALL_QUERY);
      solrQuery.setFields(SolrConstants.ID_FIELD);
      solrQuery.setRows(1);

      QueryResponse response;
      try {
        response = solr.query(solrQuery);
      } catch (final SolrServerException e) {
View Full Code Here

TOP

Related Classes of org.apache.solr.client.solrj.SolrQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.