Package org.apache.solr.client.solrj

Examples of org.apache.solr.client.solrj.SolrServer.query()


      solrQuery.setStart(solrSplit.getDocBegin());
      solrQuery.setRows(numDocs);

      QueryResponse response;
      try {
        response = solr.query(solrQuery);
      } catch (final SolrServerException e) {
        throw new IOException(e);
      }

      final SolrDocumentList solrDocs = response.getResults();
View Full Code Here


      solrQuery.setFields(SolrConstants.ID_FIELD);
      solrQuery.setRows(1);

      QueryResponse response;
      try {
        response = solr.query(solrQuery);
      } catch (final SolrServerException e) {
        throw new IOException(e);
      }

      int numResults = (int)response.getResults().getNumFound();
View Full Code Here

      solrQuery.setStart(solrSplit.getDocBegin());
      solrQuery.setRows(numDocs);

      QueryResponse response;
      try {
        response = solr.query(solrQuery);
      } catch (final SolrServerException e) {
        throw new IOException(e);
      }

      final SolrDocumentList solrDocs = response.getResults();
View Full Code Here

        final ModifiableSolrParams params = new ModifiableSolrParams();
        params.set("qt", "/");
        params.set("q", field + ":" + term);
        final SolrRequest req = new QueryRequest(params);

        final QueryResponse resp = solr.query(params);
        System.out.println("resp: " + resp);
    }
}
View Full Code Here

        SolrQuery query = new SolrQuery(sb.toString());
        query.setRows(1);
        query.setFields(exampleIdField);
        try {
            SolrServer solrServer = getActiveSolrServer();
            return solrServer.query(query).getResults().size() > 0;
        } catch (SolrServerException e) {
            String msg = String.format(
                "Error while fetching topics for examples modified after '%s' on Solr Core '%s'.",
                utcIsoDate, solrCoreId);
            throw new TrainingSetException(msg, e);
View Full Code Here

        query.addSortField(exampleIdField, SolrQuery.ORDER.asc);
        query.set("rows", batchSize + 1);
        String nextExampleId = null;
        try {
            int count = 0;
            QueryResponse response = solrServer.query(query);
            for (SolrDocument result : response.getResults()) {
                if (count == batchSize) {
                    nextExampleId = result.getFirstValue(exampleIdField).toString();
                } else {
                    count++;
View Full Code Here

                // use filter queries to leverage the Solr cache explicitly
                metadataQuery.addFilterQuery(entryTypeField + ":" + METADATA_ENTRY);
                metadataQuery
                        .addFilterQuery(conceptUriField + ":" + ClientUtils.escapeQueryChars(conceptUri));
                metadataQuery.setFields(conceptUriField, broaderField, primaryTopicUriField);
                SolrDocument metadata = solrServer.query(metadataQuery).getResults().get(0);
                String primaryTopicUri = (String) metadata.getFirstValue(primaryTopicUriField);
                suggestedTopics.add(new TopicSuggestion(conceptUri, primaryTopicUri, metadata
                        .getFieldValues(broaderField), score));
            }
        } catch (SolrServerException e) {
View Full Code Here

        query.addFilterQuery(entryTypeField + ":" + METADATA_ENTRY);
        query.addFilterQuery(broaderField + ":" + ClientUtils.escapeQueryChars(broadTopicId));
        query.addField(conceptUriField);
        query.addSortField(conceptUriField, SolrQuery.ORDER.asc);
        try {
            for (SolrDocument result : solrServer.query(query).getResults()) {
                narrowerConcepts.add(result.getFirstValue(conceptUriField).toString());
            }
        } catch (SolrServerException e) {
            String msg = String.format("Error while fetching narrower topics of '%s' on Solr Core '%s'.",
                broadTopicId, solrCoreId);
View Full Code Here

        SolrServer solrServer = getActiveSolrServer();
        SolrQuery query = new SolrQuery("*:*");
        query.addFilterQuery(conceptUriField + ":" + ClientUtils.escapeQueryChars(id));
        query.addField(broaderField);
        try {
            for (SolrDocument result : solrServer.query(query).getResults()) {
                // there should be only one results
                Collection<Object> broaderFieldValues = result.getFieldValues(broaderField);
                if (broaderFieldValues == null) {
                    continue;
                }
View Full Code Here

        if (broaderField != null) {
            // find any topic with an empty broaderField
            query.addFilterQuery(" -" + broaderField + ":" + SOLR_NON_EMPTY_FIELD);
        }
        try {
            QueryResponse response = solrServer.query(query);
            if (response.getResults().size() >= MAX_ROOTS) {
                log.warn(String.format("TopicClassifier '%s' has more than %d registered topic roots."
                                       + " Some roots might be ignored.", engineName, MAX_ROOTS));
            }
            for (SolrDocument result : response.getResults()) {
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.