Package org.apache.solr.client.solrj

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


                // batch over all the indexed topics
                if (offset != null) {
                    query.addFilterQuery(conceptUriField + ":["
                                         + ClientUtils.escapeQueryChars(offset.toString()) + " TO *]");
                }
                QueryResponse response = solrServer.query(query);
                int count = 0;
                List<SolrDocument> batchDocuments = new ArrayList<SolrDocument>();
                for (SolrDocument result : response.getResults()) {
                    String conceptId = result.getFirstValue(conceptUriField).toString();
                    if (count == batchSize) {
View Full Code Here


        SolrServer solrServer = getActiveSolrServer();
        try {
            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)
                // fetch any old values to update (all metadata fields are assumed to be stored)s
                Map<String,Collection<Object>> fieldValues = new HashMap<String,Collection<Object>>();
                for (String fieldName : result.getFieldNames()) {
                    fieldValues.put(fieldName, result.getFieldValues(fieldName));
View Full Code Here

        SolrServer solrServer = getActiveSolrServer();
        SolrQuery query = new SolrQuery("*:*");
        query.addFilterQuery(entryTypeField + ":" + METADATA_ENTRY);
        query.addFilterQuery(conceptUriField + ":" + ClientUtils.escapeQueryChars(conceptId));
        try {
            SolrDocumentList results = solrServer.query(query).getResults();
            if (results.isEmpty()) {
                throw new ClassifierException(String.format("'%s' is not a registered topic", conceptId));
            }
            SolrDocument metadata = results.get(0);
            Float precision = computeMeanValue(metadata, precisionField);
View Full Code Here

    // query a random server
    params.set("shards", shards);
    int which = r.nextInt(clients.size());
    SolrServer client = clients.get(which);
    QueryResponse rsp = client.query(params);

    compareResponses(rsp, controlRsp);

    if (stress>0) {
      System.out.println("starting stress...");
View Full Code Here

          public void run() {
            for (int j=0; j<stress; j++) {
              int which = r.nextInt(clients.size());
              SolrServer client = clients.get(which);
              try {
                QueryResponse rsp = client.query(new ModifiableSolrParams(params));
                if (verifyStress) {
                  compareResponses(rsp, controlRsp);                 
                }
              } catch (SolrServerException e) {
                throw new RuntimeException(e);
View Full Code Here

        QueryResponse response;
        final SolrServer server = getServer();
        try {
            response = AccessController.doPrivileged(new PrivilegedExceptionAction<QueryResponse>() {
                public QueryResponse run() throws IOException, SolrServerException {
                        return server.query(query, METHOD.POST);
                }
            });
        } catch (PrivilegedActionException pae) {
            Exception e = pae.getException();
            if(e instanceof SolrServerException){
View Full Code Here

    protected QueryResponse executeSolrQuery(String query) throws SolrServerException {
        SolrQuery solrQuery = new SolrQuery();
        solrQuery.setQuery(query);
        SolrServer solrServer = solrFixtures.getServer();
        return solrServer.query(solrQuery);
    }

    @BeforeClass
    public static void beforeClass() throws Exception {
        SolrFixtures.createSolrFixtures();
View Full Code Here

            }

            SolrParams solrParams = SolrParams.toSolrParams( list );
            logger.debug( "Search:" + list.toString() );

            QueryResponse query = server.query( solrParams );

            SolrDocumentList results = query.getResults();

            List<EntityReference> references = new ArrayList<EntityReference>( results.size() );
            for( SolrDocument result : results )
View Full Code Here

        NamedList<Object> list = new NamedList<Object>();

        list.add( "q", queryString );

        QueryResponse query = server.query( SolrParams.toSolrParams( list ) );
        return query.getResults();
    }
}
View Full Code Here

        SolrServer solrServer = new EmbeddedSolrServer(coreContainer, "");

        ModifiableSolrParams params = new ModifiableSolrParams();
        params.set(CommonParams.Q, "turbowriter");

        QueryResponse res = solrServer.query(params);
        assertEquals(1, res.getResults().size());
        byte[] storedImageData = (byte[])res.getResults().get(0).getFieldValue("image");
        assertEquals(imageData, storedImageData);
       
        params.set(CommonParams.Q, "cat:Japanese");
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.