当前位置: 首页>>代码示例>>Java>>正文


Java METHOD类代码示例

本文整理汇总了Java中org.apache.solr.client.solrj.SolrRequest.METHOD的典型用法代码示例。如果您正苦于以下问题:Java METHOD类的具体用法?Java METHOD怎么用?Java METHOD使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


METHOD类属于org.apache.solr.client.solrj.SolrRequest包,在下文中一共展示了METHOD类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSolrExceptionCodeNotFromSolr

import org.apache.solr.client.solrj.SolrRequest.METHOD; //导入依赖的package包/类
/**
 * test that SolrExceptions thrown by HttpSolrServer can
 * correctly encapsulate http status codes even when not on the list of
 * ErrorCodes solr may return.
 */
public void testSolrExceptionCodeNotFromSolr() throws IOException, SolrServerException {
  final int status = 527;
  assertEquals(status + " didn't generate an UNKNOWN error code, someone modified the list of valid ErrorCode's w/o changing this test to work a different way",
               ErrorCode.UNKNOWN, ErrorCode.getErrorCode(status));

  HttpSolrServer server = new HttpSolrServer(jetty.getBaseUrl().toString() +
                                             "/debug/foo");
  try {
    DebugServlet.setErrorCode(status);
    try {
      SolrQuery q = new SolrQuery("foo");
      server.query(q, METHOD.GET);
      fail("Didn't get excepted exception from oversided request");
    } catch (SolrException e) {
      System.out.println(e);
      assertEquals("Unexpected exception status code", status, e.code());
    }
  } finally {
    server.shutdown();
    DebugServlet.clear();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:28,代码来源:BasicHttpSolrServerTest.java

示例2: executeNativeQuery

import org.apache.solr.client.solrj.SolrRequest.METHOD; //导入依赖的package包/类
@Override
public NativeQueryResult executeNativeQuery(Map<String, String[]> parameters) {
    SolrParams params = createSolrParams(parameters);

    try {
        QueryRequest request = new QueryRequest(params, METHOD.POST);
        request.setResponseParser(new InputStreamResponseParser("json"));
        QueryResponse response = request.process(this.solrClient);

        InputStream inputStream = (InputStream) response.getResponse().get("stream");
        if (inputStream != null) {
            return new SolrNativeQueryResult(inputStream);
        }

        return new SolrNativeQueryResult(this.serializeResponse(params, response));
    } catch (SolrException | SolrServerException | IOException e) {
        throw new DataRetrievalException("Could not execute direct query with parameters " + parameters.toString() + ".", e);
    }
}
 
开发者ID:Indoqa,项目名称:logspace,代码行数:20,代码来源:SolrNativeQueryService.java

示例3: getFilesList

import org.apache.solr.client.solrj.SolrRequest.METHOD; //导入依赖的package包/类
/**
 * Get list of files from the remote Solr server.
 * 
 * @param directoryName
 *            Name of the directory containing the files, or null to fetch a
 *            list of files in top-level directory.
 * @return Map of Solr config files.
 * @throws SophieException
 *             If files cannot be fetched from Solr.
 */
@SuppressWarnings("unchecked")
public static Map<String, Object> getFilesList(String directoryName) throws SophieException {
    ModifiableSolrParams params = new ModifiableSolrParams();
    if (StringUtils.isNotEmpty(directoryName)) {
        params.set("file", directoryName);
    }
    GenericSolrRequest request = new GenericSolrRequest(METHOD.GET, "/admin/file", params);
    try {
        NamedList<Object> response = Sophie.client.request(request);
        NamedList<Object> files = (NamedList<Object>) response.get("files");
        // Wrap in TreeMap so files are sorted by name.
        return new TreeMap<String, Object>(files.asMap(-1));
    } catch (SolrServerException | IOException | SolrException e) {
        throw new SophieException("Unable to fetch list of files in directory " + directoryName, e);
    }
}
 
开发者ID:fengtan,项目名称:sophie,代码行数:27,代码来源:SolrUtils.java

示例4: RigelConfig

import org.apache.solr.client.solrj.SolrRequest.METHOD; //导入依赖的package包/类
public RigelConfig(Config applicationConfig) {
    Config config = applicationConfig.getConfig("rigel");

    fieldConfig = Maps.newHashMap();
    Config fields = config.getConfig("field");

    for (String configField : getSubPaths(fields)) {
        Config conf = fields.getConfig(configField);
        FieldConfig f = new FieldConfig(configField, conf.getString("name"));
        fieldConfig.put(configField, f);
    }

    String requestMethod = config.getString("solr.request.method");
    try {
        this.solrRequestMethod = SolrRequest.METHOD.valueOf(requestMethod);
    } catch (IllegalArgumentException e) {
        throw new RuntimeException("rigel.request.method must be either GET or POST");
    }

    this.solrUrl = config.getString("solr.url");
}
 
开发者ID:semantico,项目名称:rigel,代码行数:22,代码来源:RigelContext.java

示例5: executeStreamingExpression

import org.apache.solr.client.solrj.SolrRequest.METHOD; //导入依赖的package包/类
public static RStreamingExpressionIterator executeStreamingExpression(SolrClient sc, String collection,
    String expression, String[] columnNames) throws IOException, SolrServerException {
    if (!checkResponseWriter(sc)) {
        log.error("The SolrClient's Response Writer should be: " + InputStreamResponseParser.class.getName());
    }
    SolrParams sp = new MapSolrParams(Collections.singletonMap("expr", expression));
    SolrRequest<?> sr = new GenericSolrRequest(METHOD.POST, "/stream", sp);
    NamedList<Object> nl = sc.request(sr, collection);
    InputStream stream = (InputStream) nl.get("stream");
    InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
    if (columnNames == null || columnNames.length == 0) {
        return new RStreamingExpressionIterator(reader);
    }
    return new RStreamingExpressionIterator(reader, columnNames);
}
 
开发者ID:jdyer1,项目名称:R-solr-stream,代码行数:16,代码来源:RStreamingExpressions.java

示例6: runQuery

import org.apache.solr.client.solrj.SolrRequest.METHOD; //导入依赖的package包/类
/**
 * Executes a string query.
 * 
 * @param q        a query string.
 * @param numRet   the maximum number of entries to return.  
 * @return a list of documents, an object of the type {@link org.apache.solr.common.SolrDocumentList}. 
 * @throws SolrServerException
 */
public SolrDocumentList runQuery(String q, int numRet)
    throws SolrServerException {
  SolrQuery query = new SolrQuery();
  query.setQuery(q);
  query.setRows(numRet);
  query.setFields("*", "score");
  QueryResponse rsp = mServer.query(query, METHOD.POST);
  return rsp.getResults();
}
 
开发者ID:oaqa,项目名称:knn4qa,代码行数:18,代码来源:SolrServerWrapper.java

示例7: testTimeout

import org.apache.solr.client.solrj.SolrRequest.METHOD; //导入依赖的package包/类
@Test
public void testTimeout() throws Exception {
  HttpSolrServer server = new HttpSolrServer(jetty.getBaseUrl().toString() +
                                             "/slow/foo");
  SolrQuery q = new SolrQuery("*:*");
  server.setSoTimeout(2000);
  try {
    QueryResponse response = server.query(q, METHOD.GET);
    fail("No exception thrown.");
  } catch (SolrServerException e) {
    assertTrue(e.getMessage().contains("Timeout"));
  }
  server.shutdown();
}
 
开发者ID:europeana,项目名称:search,代码行数:15,代码来源:BasicHttpSolrServerTest.java

示例8: getTimeSeries

import org.apache.solr.client.solrj.SolrRequest.METHOD; //导入依赖的package包/类
@Override
public Object[] getTimeSeries(TimeSeriesDefinition dataDefinition) {
    SolrQuery solrQuery = new SolrQuery(ALL_DOCS_QUERY);
    solrQuery.setRows(0);

    solrQuery.addFilterQuery(FIELD_GLOBAL_AGENT_ID + ":" + escapeSolr(dataDefinition.getGlobalAgentId()));
    solrQuery.addFilterQuery(getTimestampRangeQuery(dataDefinition.getTimeWindow()));
    solrQuery.addFilterQuery(dataDefinition.getPropertyId() + ":*");

    for (String eachFilterQuery : this.createFilterQueries(dataDefinition.getFilter())) {
        solrQuery.addFilterQuery(eachFilterQuery);
    }

    solrQuery.set("json.facet", this.createTimeSeriesFacets(dataDefinition));

    try {
        QueryResponse response = this.solrClient.query(solrQuery, METHOD.POST);

        List<Object> values = new ArrayList<Object>();

        Buckets buckets = Buckets.fromResponse(response, FIELD_TIMESTAMP);
        for (NamedList<Object> eachBucket : buckets) {
            if (dataDefinition.getAggregate() == Aggregate.count) {
                values.add(eachBucket.get(COUNT_FACET_NAME));
            } else {
                values.add(eachBucket.get(AGGREGATION_FACET_NAME));
            }
        }

        return values.toArray();
    } catch (SolrException | SolrServerException | IOException e) {
        throw new DataRetrievalException("Could not retrieve data.", e);
    }
}
 
开发者ID:Indoqa,项目名称:logspace,代码行数:35,代码来源:SolrEventService.java

示例9: getFileContent

import org.apache.solr.client.solrj.SolrRequest.METHOD; //导入依赖的package包/类
/**
 * Get content of a file from the remote Solr server.
 *
 * @param fileName
 *            Name of the file to fetch.
 * @return Content of the file.
 * @throws SophieException
 *             If file cannot be fetched from Solr.
 */
public static String getFileContent(String fileName) throws SophieException {
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set("file", fileName);
    GenericSolrRequest request = new GenericSolrRequest(METHOD.GET, "/admin/file", params);
    request.setResponseParser(new NoOpResponseParser());
    try {
        NamedList<Object> response = Sophie.client.request(request);
        return Objects.toString(response.get("response", 0), "");
    } catch (SolrServerException | IOException | SolrException e) {
        throw new SophieException("Unable to fetch content of file " + fileName, e);
    }
}
 
开发者ID:fengtan,项目名称:sophie,代码行数:22,代码来源:SolrUtils.java

示例10: getSolrResults

import org.apache.solr.client.solrj.SolrRequest.METHOD; //导入依赖的package包/类
private void getSolrResults() {
	try {
		QueryResponse response = solrServer.query(solrQuery, METHOD.POST);
		results = response.getResults();
	} catch (SolrServerException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:play4science,项目名称:gwap,代码行数:10,代码来源:ArtResourceSearchCacheBean.java

示例11: ContentRepositoryImpl

import org.apache.solr.client.solrj.SolrRequest.METHOD; //导入依赖的package包/类
public ContentRepositoryImpl(SolrServer solr,
        ContentItemFactory contentItemFactory, METHOD method,
        ContentItem.Schema<T> schema) {
    this.solr = checkNotNull(solr);
    this.contentItemFactory = checkNotNull(contentItemFactory);
    this.method = checkNotNull(method);
    this.schema = schema;
}
 
开发者ID:semantico,项目名称:rigel,代码行数:9,代码来源:ContentRepositoryImpl.java

示例12: categoriesAvailable

import org.apache.solr.client.solrj.SolrRequest.METHOD; //导入依赖的package包/类
public static Map<String, Object> categoriesAvailable(String catalogId, String categoryId, String productId, 
        String facetPrefix, boolean displayproducts, int viewIndex, int viewSize, List<String> queryFilters, Boolean excludeVariants, String core) {
    // create the data model
    Map<String, Object> result = new HashMap<>();
    HttpSolrClient client = null;
    QueryResponse returnMap = new QueryResponse();
    try {
        // do the basic query
        client = SolrUtil.getHttpSolrClient(core);
        // create Query Object
        String query = "inStock[1 TO *]";
        if (categoryId != null)
            query += " +cat:"+ SolrExprUtil.escapeTermFull(categoryId);
        else if (productId != null)
            query += " +productId:" + SolrExprUtil.escapeTermFull(productId);
        SolrQuery solrQuery = new SolrQuery();
        solrQuery.setQuery(query);

        if (catalogId != null)
            solrQuery.addFilterQuery("+catalog:" + SolrExprUtil.escapeTermFull(catalogId));
        
        if (excludeVariants == null) excludeVariants = SolrProductSearch.excludeVariantsDefault;
        if (excludeVariants)
            SolrProductUtil.addExcludeVariantsFilter(solrQuery);
        
        if (displayproducts) {
            if (viewSize > -1) {
                solrQuery.setRows(viewSize);
            } else
                solrQuery.setRows(50000);
            if (viewIndex > -1) {
                // 2016-04-01: This must be calculated
                //solrQuery.setStart(viewIndex);
                if (viewSize > 0) {
                    solrQuery.setStart(viewSize * viewIndex);
                }
            }
        } else {
            solrQuery.setFields("cat");
            solrQuery.setRows(0);
        }
        
        if(UtilValidate.isNotEmpty(facetPrefix)){
            solrQuery.setFacetPrefix(facetPrefix);
        }
        
        solrQuery.setFacetMinCount(0);
        solrQuery.setFacet(true);
        solrQuery.addFacetField("cat");
        solrQuery.setFacetLimit(-1);
        if (Debug.verboseOn()) Debug.logVerbose("solr: solrQuery: " + solrQuery, module);
        returnMap = client.query(solrQuery,METHOD.POST);
        result.put("rows", returnMap);
        result.put("numFound", returnMap.getResults().getNumFound());
    } catch (Exception e) {
        Debug.logError(e.getMessage(), module);
    }
    return result;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:60,代码来源:SolrCategoryUtil.java

示例13: executeQuery

import org.apache.solr.client.solrj.SolrRequest.METHOD; //导入依赖的package包/类
protected QueryResponse executeQuery(SolrQuery query) throws SolrServerException {
String requestMethod = SolrMeterConfiguration.getProperty(SolrMeterConfiguration.QUERY_METHOD, "GET");
return executor.getSolrServer().query(query, METHOD.valueOf(requestMethod));
 }
 
开发者ID:lafourchette,项目名称:solrmeter,代码行数:5,代码来源:QueryOperation.java

示例14: getAgentActivities

import org.apache.solr.client.solrj.SolrRequest.METHOD; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public AgentActivities getAgentActivities(int start, int count, int durationSeconds, int steps, String sort) {
    SolrQuery solrQuery = new SolrQuery(ALL_DOCS_QUERY);
    solrQuery.setRows(0);

    Date endDate = new Date();
    Date startDate = new Date(endDate.getTime() - SECONDS.toMillis(durationSeconds));

    solrQuery.addFilterQuery(getTimestampRangeQuery(startDate, endDate));

    TermsFacet agentFacet = new TermsFacet(FIELD_GLOBAL_AGENT_ID, FIELD_GLOBAL_AGENT_ID);
    agentFacet.setOffset(start);
    agentFacet.setLimit(count);
    agentFacet.setMincount(0);
    agentFacet.setNumBuckets(true);
    agentFacet.setSort(sort);
    agentFacet.addSubFacet(
        new RangeFacet(FIELD_TIMESTAMP, FIELD_TIMESTAMP, startDate, endDate, GapUnit.SECONDS, durationSeconds / steps));

    solrQuery.set("json.facet", FacetList.toJsonString(agentFacet));

    try {
        AgentActivities result = new AgentActivities();

        QueryResponse response = this.solrClient.query(solrQuery, METHOD.POST);

        Buckets agentBuckets = Buckets.fromResponse(response, FIELD_GLOBAL_AGENT_ID);
        result.setOffset(start);
        result.setTotalCount(agentBuckets.getNumBuckets());

        int maxHistoryValue = 0;

        for (NamedList<Object> eachAgentBucket : agentBuckets) {
            AgentActivity agentActivity = new AgentActivity();

            agentActivity.setGlobalAgentId((String) eachAgentBucket.get(VALUE_FACET_NAME));
            agentActivity.setEventCount(Buckets.getInt(eachAgentBucket, COUNT_FACET_NAME));

            int[] history = new int[steps];

            Buckets historyBuckets = Buckets.fromFacet((NamedList<Object>) eachAgentBucket.get(FIELD_TIMESTAMP));
            for (int i = 0; i < Math.min(historyBuckets.getBucketCount(), history.length); i++) {
                NamedList<Object> historyBucket = historyBuckets.getBucket(i);

                int historyValue = Buckets.getInt(historyBucket, COUNT_FACET_NAME);
                history[i] = historyValue;
                maxHistoryValue = Math.max(maxHistoryValue, historyValue);
            }
            agentActivity.setHistory(history);

            result.add(agentActivity);
        }

        result.setMaxHistoryValue(maxHistoryValue);

        return result;
    } catch (SolrException | SolrServerException | IOException e) {
        throw new DataRetrievalException("Could not retrieve Agent activities.", e);
    }
}
 
开发者ID:Indoqa,项目名称:logspace,代码行数:62,代码来源:SolrAgentService.java

示例15: query

import org.apache.solr.client.solrj.SolrRequest.METHOD; //导入依赖的package包/类
public QueryResponse query(SolrQuery sq) throws SolrServerException
{
    return server.query(sq, METHOD.POST);
}
 
开发者ID:outermedia,项目名称:solr-fusion,代码行数:5,代码来源:SolrTestServer.java


注:本文中的org.apache.solr.client.solrj.SolrRequest.METHOD类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。