Package org.apache.solr.common

Examples of org.apache.solr.common.SolrDocumentList


        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)
            {
                return true;
            }
        }
        return false;
View Full Code Here


                    + 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!)
                updated = updated
                        | setValue(applicationService, rp, itemsInPMCTP,
                                String.valueOf(results.getNumFound()));
            }

            if (updated)
            {
                applicationService.saveOrUpdate(ResearcherPage.class, rp);
View Full Code Here

        DSpace dspace = new DSpace();

        SolrLogger indexer = dspace.getServiceManager().getServiceByName(SolrLogger.class.getName(),SolrLogger.class);

       
        SolrDocumentList sdl = indexer.getRawData(Constants.ITEM);
        System.out.println("Found " + sdl.getNumFound()
                + " access in the statistics core");
        HttpSolrServer solr = indexer.getSolr();
        indexer.deleteByType(Constants.ITEM);
        solr.commit();
        System.out.println("Remove old data");
        Context context = new Context();
        context.turnOffAuthorisationSystem();
        int i = 0;
        for (SolrDocument sd : sdl)
        {
            i++;
            System.out.println("Processed access #" + i + " of "
                    + sdl.getNumFound());
            SolrInputDocument sdi = ClientUtils.toSolrInputDocument(sd);
            Integer id = (Integer) sd.getFieldValue("id");
            Integer type = (Integer) sd.getFieldValue("type");

            DSpaceObject dso = DSpaceObject.find(context, type, id);
           
            // Do any additional indexing, depends on the plugins
            List<SolrStatsIndexPlugin> solrServiceIndexPlugins = new DSpace()
                    .getServiceManager().getServicesByType(
                            SolrStatsIndexPlugin.class);
            for (SolrStatsIndexPlugin solrServiceIndexPlugin : solrServiceIndexPlugins)
            {
                solrServiceIndexPlugin.additionalIndex(null, dso,
                        sdi);
            }

           
            context.removeCached(dso, id);
            solr.add(sdi);
        }
        solr.commit();
        solr.optimize();

        sdl = indexer.getRawData(CrisConstants.RP_TYPE_ID);
        System.out.println("Found " + sdl.getNumFound()
                + " access in the RP statistics core");
        HttpSolrServer rpsolr = indexer.getSolr();
        indexer.deleteByType(CrisConstants.RP_TYPE_ID);
        rpsolr.commit();

        System.out.println("Remove old data");
       
        ApplicationService as = dspace.getServiceManager().getServiceByName(
                "applicationService", ApplicationService.class);
        i = 0;
        for (SolrDocument sd : sdl)
        {
            i++;
            System.out.println("Processed RP access #" + i + " of "
                    + sdl.getNumFound());
            SolrInputDocument sdi = ClientUtils.toSolrInputDocument(sd);
            Integer id = (Integer) sd.getFieldValue("id");

            ResearcherPage rp = as.get(ResearcherPage.class, id);
            if (rp == null)
View Full Code Here

        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)
            {
                return true;
            }
        }
        return false;
View Full Code Here

        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();

        String rp_dept = "";
        while (iter.hasNext())
        {
            SolrDocument publication = iter.next();
View Full Code Here

        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();

        String rp_status = "";
        while (iter.hasNext())
        {
            SolrDocument publication = iter.next();
View Full Code Here

        String inner = escape("title", "Generic Search")+",\n";
        if (results == null) {
            inner += escape("totalResults", "0")+",\n";
        } else {
            SolrDocumentList list = results.getResults();
            inner += escape("totalResults", list.getNumFound())+",\n";
        }
        inner += escape("startIndex", start)+",\n";
        inner += escape("itemsPerPage", rows)+"\n";
        return "\"OpenSearchResponse\": {\n"+inner+"\n}";
    }
View Full Code Here

     * @param results: The Solr results
     * @return String: Results section in JSON
     */
    private String listResponse(QueryResponse results) {
        // Render each row
        SolrDocumentList list = results.getResults();
        List<String> rows = new ArrayList();
        for (SolrDocument doc : list) {
            rows.add(renderRow(doc));
        }

View Full Code Here

      response = solr.query(new SolrQuery(searchUID + ":\"" + hit.getUniqueKey() + "\""));
    } catch (final SolrServerException e) {
      throw SolrWriter.makeIOException(e);
    }

    final SolrDocumentList docList = response.getResults();
    if (docList.getNumFound() == 0) {
      return null;
    }

    return buildDetails(docList.get(0));
  }
View Full Code Here

      response = solr.query(new SolrQuery(buf.toString()));
    } catch (final SolrServerException e) {
      throw SolrWriter.makeIOException(e);
    }

    final SolrDocumentList docList = response.getResults();
    if (docList.size() < hits.length) {
      throw new RuntimeException("Missing hit details! Found: " +
                                 docList.size() + ", expecting: " +
                                 hits.length);
    }

    /* Response returned from SOLR server may be out of
     * order. So we make sure that nth element of HitDetails[]
View Full Code Here

TOP

Related Classes of org.apache.solr.common.SolrDocumentList

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.