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


Java QParser.getQuery方法代码示例

本文整理汇总了Java中org.apache.solr.search.QParser.getQuery方法的典型用法代码示例。如果您正苦于以下问题:Java QParser.getQuery方法的具体用法?Java QParser.getQuery怎么用?Java QParser.getQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.search.QParser的用法示例。


在下文中一共展示了QParser.getQuery方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: olderDocumentsExists

import org.apache.solr.search.QParser; //导入方法依赖的package包/类
/**
 * Searches the index, if older documents exists. Updates the solr query response.
 *
 * @param req - the solr query request information
 * @param rsp - the solr query response information
 * @return true if the hit count is greater zero, otherwise false
 * @throws SyntaxError, IOException if bad things happen
 */
private boolean olderDocumentsExists(String queryString, SolrQueryRequest req, SolrQueryResponse rsp) throws SyntaxError, IOException {
    String defType = req.getParams().get(QueryParsing.DEFTYPE, QParserPlugin.DEFAULT_QTYPE);

    QParser queryParser = QParser.getParser(queryString, defType, req);
    Query query = queryParser.getQuery();

    TotalHitCountCollector totalHitCountCollector = new TotalHitCountCollector();
    req.getSearcher().search(query, totalHitCountCollector);

    rsp.add("query", String.format("%s:[* TO NOW-%s]", queryField, timeSeriesAge));
    rsp.add("queryTechnical", queryString);
    rsp.add("removedDocuments", totalHitCountCollector.getTotalHits());

    return totalHitCountCollector.getTotalHits() != 0;
}
 
开发者ID:ChronixDB,项目名称:chronix.server,代码行数:24,代码来源:ChronixRetentionHandler.java

示例2: getQuery

import org.apache.solr.search.QParser; //导入方法依赖的package包/类
private Query getQuery(DeleteUpdateCommand cmd) {
  Query q;
  try {
    // move this higher in the stack?
    QParser parser = QParser.getParser(cmd.getQuery(), "lucene", cmd.req);
    q = parser.getQuery();
    q = QueryUtils.makeQueryable(q);

    // Make sure not to delete newer versions
    if (ulog != null && cmd.getVersion() != 0 && cmd.getVersion() != -Long.MAX_VALUE) {
      BooleanQuery bq = new BooleanQuery();
      bq.add(q, Occur.MUST);
      SchemaField sf = ulog.getVersionInfo().getVersionField();
      ValueSource vs = sf.getType().getValueSource(sf, null);
      ValueSourceRangeFilter filt = new ValueSourceRangeFilter(vs, null, Long.toString(Math.abs(cmd.getVersion())), true, true);
      FunctionRangeQuery range = new FunctionRangeQuery(filt);
      bq.add(range, Occur.MUST);
      q = bq;
    }

    return q;

  } catch (SyntaxError e) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:DirectUpdateHandler2.java

示例3: parse

import org.apache.solr.search.QParser; //导入方法依赖的package包/类
@Override
public Query parse() throws SyntaxError {
  String filter = localParams.get(getParentFilterLocalParamName());
  QParser parentParser = subQuery(filter, null);
  Query parentQ = parentParser.getQuery();

  String queryText = localParams.get(QueryParsing.V);
  // there is no child query, return parent filter from cache
  if (queryText == null || queryText.length()==0) {
                SolrConstantScoreQuery wrapped = new SolrConstantScoreQuery(getFilter(parentQ));
                wrapped.setCache(false);
                return wrapped;
  }
  QParser childrenParser = subQuery(queryText, null);
  Query childrenQuery = childrenParser.getQuery();
  return createQuery(parentQ, childrenQuery);
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:BlockJoinParentQParser.java

示例4: parse

import org.apache.solr.search.QParser; //导入方法依赖的package包/类
@Override
public Query parse() throws SyntaxError {

	SolrParams localParams = getLocalParams();
	SolrParams params = getParams();
	SolrParams solrParams = SolrParams.wrapDefaults(localParams, params);
	QParser baseParser = subQuery(solrParams.get(QueryParsing.V), null);
       Query startNodesQuery = baseParser.getQuery();	
       String fromField = localParams.get("from", "node_id");
	String toField = localParams.get("to", "edge_ids");
	
	QParser traversalBaseParser = subQuery(localParams.get("traversalFilter"), null);		
       Query traversalFilter = traversalBaseParser.getQuery();	
       
       // TODO: un-invert this logic
	boolean onlyLeafNodes = Boolean.valueOf(localParams.get("returnOnlyLeaf", "false"));
	boolean returnStartNodes = Boolean.valueOf(localParams.get("returnRoot", "true"));
	int maxDepth = Integer.valueOf(localParams.get("maxDepth", "-1"));
	
	GraphQuery gq = new GraphQuery(startNodesQuery, fromField, toField, traversalFilter);
	gq.setMaxDepth(maxDepth);
	gq.setOnlyLeafNodes(onlyLeafNodes);
	gq.setReturnStartNodes(returnStartNodes);
	return gq;
}
 
开发者ID:kwatters,项目名称:solrgraph,代码行数:26,代码来源:GraphQueryParser.java

示例5: parse

import org.apache.solr.search.QParser; //导入方法依赖的package包/类
@Override
public Query parse() throws SyntaxError {
  if (localParams == null) {
    throw new SyntaxError ("join query parser must be invoked using localParams");
  }
  String filter = localParams.get(getParentFilterLocalParamName());
  QParser parentParser = subQuery(filter, null);
  Query parentQ = parentParser.getQuery();

  String queryText = localParams.get(QueryParsing.V);
  // there is no child query, return parent filter from cache
  if (queryText == null || queryText.length()==0) {
    SolrConstantScoreQuery wrapped = new SolrConstantScoreQuery(getFilter(parentQ));
    wrapped.setCache(false);
    return wrapped;
  }
  QParser childrenParser = subQuery(queryText, null);
  Query childrenQuery = childrenParser.getQuery();
  return createQuery(parentQ, childrenQuery);
}
 
开发者ID:safarijv,项目名称:ifpress-solr-plugin,代码行数:21,代码来源:ScoringParentQParser.java

示例6: parseQueryString

import org.apache.solr.search.QParser; //导入方法依赖的package包/类
public static Query parseQueryString(String qString, SolrQueryRequest req) {
    try {
        QParser parser = QParser.getParser(qString, req.getParams().get("defType"), req);
        return parser.getQuery();
    } catch (SyntaxError e) {
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
                "Syntax error in query: " + qString + ".");
    }
}
 
开发者ID:careerbuilder,项目名称:semantic-knowledge-graph,代码行数:10,代码来源:ParseUtility.java

示例7: getLocalParams

import org.apache.solr.search.QParser; //导入方法依赖的package包/类
protected Query getLocalParams(String qfield, String lparams) throws SyntaxError {
  QParser nested = parser.subQuery(lparams, null);
  return nested.getQuery();
}
 
开发者ID:europeana,项目名称:search,代码行数:5,代码来源:SolrQueryParserBase.java

示例8: parseQuery

import org.apache.solr.search.QParser; //导入方法依赖的package包/类
public static Query parseQuery(SolrQueryRequest request, String q) throws SyntaxError {
    final SolrParams params = request.getParams();
    String defType = params.get(QueryParsing.DEFTYPE, EDISMAX);
    QParser parser = QParser.getParser(q, defType, request);
    return parser.getQuery();
}
 
开发者ID:DiceTechJobs,项目名称:SolrPlugins,代码行数:7,代码来源:SearchComponentHelper.java

示例9: prepare

import org.apache.solr.search.QParser; //导入方法依赖的package包/类
@Override
public void prepare(ResponseBuilder rb) throws IOException
{

  SolrQueryRequest req = rb.req;
  SolrParams params = req.getParams();
  if (!params.getBool(COMPONENT_NAME, true)) {
    return;
  }
  SolrQueryResponse rsp = rb.rsp;

  // Set field flags    
  ReturnFields returnFields = new SolrReturnFields( req );
  rsp.setReturnFields( returnFields );
  int flags = 0;
  if (returnFields.wantsScore()) {
    flags |= SolrIndexSearcher.GET_SCORES;
  }
  rb.setFieldFlags( flags );

  String defType = params.get(QueryParsing.DEFTYPE, QParserPlugin.DEFAULT_QTYPE);

  // get it from the response builder to give a different component a chance
  // to set it.
  String queryString = rb.getQueryString();
  if (queryString == null) {
    // this is the normal way it's set.
    queryString = params.get( CommonParams.Q );
    rb.setQueryString(queryString);
  }

  try {
    QParser parser = QParser.getParser(rb.getQueryString(), defType, req);
    Query q = parser.getQuery();
    if (q == null) {
      // normalize a null query to a query that matches nothing
      q = new BooleanQuery();        
    }
    rb.setQuery( q );
    rb.setSortSpec( parser.getSort(true) );
    rb.setQparser(parser);
    
    final String cursorStr = rb.req.getParams().get(CursorMarkParams.CURSOR_MARK_PARAM);
    if (null != cursorStr) {
      final CursorMark cursorMark = new CursorMark(rb.req.getSchema(),
                                                   rb.getSortSpec());
      cursorMark.parseSerializedTotem(cursorStr);
      rb.setCursorMark(cursorMark);
    }

    String[] fqs = req.getParams().getParams(CommonParams.FQ);
    if (fqs!=null && fqs.length!=0) {
      List<Query> filters = rb.getFilters();
      // if filters already exists, make a copy instead of modifying the original
      filters = filters == null ? new ArrayList<Query>(fqs.length) : new ArrayList<Query>(filters);
      for (String fq : fqs) {
        if (fq != null && fq.trim().length()!=0) {
          QParser fqp = QParser.getParser(fq, null, req);
          filters.add(fqp.getQuery());
        }
      }
      // only set the filters if they are not empty otherwise
      // fq=&someotherParam= will trigger all docs filter for every request 
      // if filter cache is disabled
      if (!filters.isEmpty()) {
        rb.setFilters( filters );
      }
    }
  } catch (SyntaxError e) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
  }

  if (params.getBool(GroupParams.GROUP, false)) {
    prepareGrouping(rb);
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:77,代码来源:QueryComponent.java


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