Package org.apache.solr.client.solrj

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


        queryString.append(id);
        queryString.append('\"');
        query.setQuery(queryString.toString());
        QueryResponse response;
        try {
            response = solrServer.query(query);
            SolrDocumentList results = response.getResults();
            if (results != null && results.size() > 0) {
                SolrDocument result = results.get(0);
                content = (byte[]) result.getFieldValue(SolrFieldName.BINARYCONTENT.toString());
                mimeType = (String) result.getFieldValue(SolrFieldName.MIMETYPE.toString());
View Full Code Here


      CoreContainer coreContainer = initializer.initialize();
      SolrServer solrServer = new EmbeddedSolrServer(coreContainer, "");

      ModifiableSolrParams solrParams = new ModifiableSolrParams();
      solrParams.add("q", "annotation:Francesco");
      QueryResponse queryResponse = solrServer.query(solrParams);

      /* check the result contains only one doc with 2 annotations of the mock CAS */
      assertTrue(queryResponse != null);
      SolrDocumentList results = queryResponse.getResults();
      assertTrue(results.getNumFound() == 1);
View Full Code Here

        queryString.append(id);
        queryString.append('\"');
        query.setQuery(queryString.toString());
        QueryResponse response;
        try {
            response = solrServer.query(query);
            SolrDocumentList results = response.getResults();
            if (results != null && results.size() > 0) {
                SolrDocument result = results.get(0);
                content = (byte[]) result.getFieldValue(SolrFieldName.BINARYCONTENT.toString());
                mimeType = (String) result.getFieldValue(SolrFieldName.MIMETYPE.toString());
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

            UpdateRequest request = new UpdateRequest();
            for (String conceptId : conceptIds) {
                SolrQuery query = new SolrQuery("*:*");
                query.addFilterQuery(entryTypeField + ":" + METADATA_ENTRY);
                query.addFilterQuery(conceptUriField + ":" + ClientUtils.escapeQueryChars(conceptId));
                for (SolrDocument result : solrServer.query(query).getResults()) {
                    // there should be only one (or none: tolerated)
                    SolrInputDocument newEntry = new SolrInputDocument();
                    for (String fieldName : result.getFieldNames()) {
                        if (!invalidatedFields.contains(fieldName)) {
                            newEntry.setField(fieldName, result.getFieldValues(fieldName));
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.