Examples of SolrDocumentList


Examples of org.apache.solr.common.SolrDocumentList

 
  public String topSuggestion(String spelling)
          throws SolrServerException {
    query.setQuery("wordNGram:"+spelling); //<co id="co.dym.field"/>
    QueryResponse response = solr.query(query);
    SolrDocumentList dl = response.getResults();
    Iterator<SolrDocument> di = dl.iterator();
    float maxDistance = 0;
    String suggestion = null;
    while (di.hasNext()) {
      SolrDocument doc = di.next();
      String word = (String) doc.getFieldValue("word");
View Full Code Here

Examples of org.apache.solr.common.SolrDocumentList

  }

  public String[] search(final SolrQuery query, final String retrievedField)
  throws SolrServerException, IOException {
    final QueryResponse response = this.getServer().query(query);
    final SolrDocumentList docList = response.getResults();

    final int size = docList.size();
    final String docIDs[] = new String[size];
    SolrDocument doc = null;
    for (int i = 0; i < size; i++) {
      doc = docList.get(i);
      docIDs[i] = (String) doc.getFieldValue(retrievedField);
    }
    return docIDs;
  }
View Full Code Here

Examples of org.apache.solr.common.SolrDocumentList

    query.setRequestHandler("keyword");
    query.setIncludeScore(true);

    // should match the two documents, with same score
    QueryResponse response = getWrapper().getServer().query(query);
    SolrDocumentList docList = response.getResults();
    assertEquals(2, docList.getNumFound());
    float score1 = (Float) docList.get(0).getFieldValue("score");
    float score2 = (Float) docList.get(1).getFieldValue("score");
    Assert.assertTrue("Score should be identical", score1 == score2);

    // should match the two documents, but should assign different score
    // id2 should receive better score than id1
    query = new SolrQuery();
    query.setQuery("café");
    query.setRequestHandler("keyword");
    query.setIncludeScore(true);

    response = getWrapper().getServer().query(query);
    docList = response.getResults();
    assertEquals(2, docList.getNumFound());
    if (docList.get(0).getFieldValue("url").equals("id1")) {
      score1 = (Float) docList.get(0).getFieldValue("score");
      score2 = (Float) docList.get(1).getFieldValue("score");
    }
    else {
      score2 = (Float) docList.get(0).getFieldValue("score");
      score1 = (Float) docList.get(1).getFieldValue("score");
    }
    Assert.assertTrue("id2 should get higher score than id1", score1 < score2);
  }
View Full Code Here

Examples of org.apache.solr.common.SolrDocumentList

            String connection, String value) throws SearchServiceException
    {

        String query = "type:" + connection + " AND focus_val:\"" + value +"\"" + " AND entity:"+ ConstantNetwork.ENTITY_DEPT;
        QueryResponse rsp = shootQuery(query, false, null);
        SolrDocumentList docs = rsp.getResults();
        if (docs != null)
        {
            if (docs.getNumFound() > 0)
            {
                return true;
            }
        }
        return false;
View Full Code Here

Examples of org.apache.solr.common.SolrDocumentList

    {
        BarrChartStatisticDatasBean totalResolutBean = new BarrChartStatisticDatasBean(
                key1, key2, key3);
        totalResolutBean.setName(key2);
        totalResolutBean.setHits(1);
        SolrDocumentList sdl = (SolrDocumentList) solrResponse.getResponse()
                .get("response");
        totalResolutBean.setDataTable(new String[][] { new String[] { Long
                .toString(sdl.getNumFound()) } });
        return totalResolutBean;
    }
View Full Code Here

Examples of org.apache.solr.common.SolrDocumentList

                    + "\"");
            solrQuery.setFields(fields);
            solrQuery.setRows(Integer.MAX_VALUE);
            rsp = getService().getSearcher().search(solrQuery);

            SolrDocumentList rows = rsp.getResults();

            external: for (String conn : connections)
            {
                Iterator<SolrDocument> iter = rows.iterator();
                internal: while (iter.hasNext())
                {
                    DTOMetric metric = new DTOMetric();

                    SolrDocument publication = iter.next();
View Full Code Here

Examples of org.apache.solr.common.SolrDocumentList

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

Examples of org.apache.solr.common.SolrDocumentList

                // and all the item modified today and archived yesterday
                query.setQuery("(item.lastmodified:(NOW/DAY-1DAY) AND dateaccessioned:(NOW/DAY-1DAY)) OR ((item.lastmodified:(NOW/DAY) AND dateaccessioned:(NOW/DAY-1DAY)))");
            }

            QueryResponse qResponse = searchService.search(query);
            SolrDocumentList results = qResponse.getResults();

            // Only add to buffer if there are new items
            if (results.getNumFound() > 0)

            {
                if (!isFirst)
                {
                    emailText
                            .append("\n---------------------------------------\n");
                }
                else
                {
                    isFirst = false;
                }

                emailText
                        .append(I18nUtil.getMessage(
                                "org.dspace.eperson.Subscribe.new-items",
                                supportedLocale)).append(" ").append(rpkey)
                        .append(": ").append(results.getNumFound())
                        .append("\n\n");

                for (SolrDocument solrDoc : results)

                {
View Full Code Here

Examples of org.apache.solr.common.SolrDocumentList

        {
            solrQuery.setStart(start);
            solrQuery.setRows(offset);
        }
        QueryResponse rsp = getService().getSearcher().search(solrQuery);
        SolrDocumentList publications = rsp.getResults();
        System.out.println(publications.getNumFound());
        List<VisualizationGraphNode> result = null;
        boolean endwhile = false;
        while (((publications.getNumFound() + offset) > start)
                && endwhile == false)
        {
            if (start > 0 && !NOT_PAGINATION)
            {
                solrQuery.setStart(start);
                solrQuery.setRows(offset);
                rsp = getService().getSearcher().search(solrQuery);
                publications = rsp.getResults();
            }

            start = (start + 1) + offset;
            // for each publication get authority's authors facets
            Iterator<SolrDocument> iter = publications.iterator();
            int counter = 0;
            external: while (iter.hasNext())
            {

                counter++;
                log.debug("" + (start == 0 ? counter : (start + counter))
                        + " of " + publications.getNumFound());
                System.out.println(getConnectionName() + " - " + counter);

                result = new ArrayList<VisualizationGraphNode>();

                Integer pubId = null;
View Full Code Here

Examples of org.apache.solr.common.SolrDocumentList

        {
            solrQuery.setStart(start);
            solrQuery.setRows(offset);
        }
        QueryResponse rsp = getService().getSearcher().search(solrQuery);
        SolrDocumentList publications = rsp.getResults();
        System.out.println(publications.getNumFound());
        List<VisualizationGraphNode> result = null;
        boolean endwhile = false;
        while (((publications.getNumFound() + offset) > start)
                && endwhile == false)
        {
            if (start > 0 && !NOT_PAGINATION)
            {
                solrQuery.setStart(start);
                solrQuery.setRows(offset);
                rsp = getService().getSearcher().search(solrQuery);
                publications = rsp.getResults();
            }

            start = (start + 1) + offset;
            // for each publication get authority's authors facets
            Iterator<SolrDocument> iter = publications.iterator();
            int counter = 0;
            external: while (iter.hasNext())
            {

                counter++;
                log.debug("" + (start == 0 ? counter : (start + counter))
                        + " of " + publications.getNumFound());
                System.out.println(getConnectionName() + " - " + counter);

                result = new ArrayList<VisualizationGraphNode>();

                Integer pubId = null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.