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


Java QParser.getParser方法代码示例

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


在下文中一共展示了QParser.getParser方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: prepare

import org.apache.solr.search.QParser; //导入方法依赖的package包/类
@Override
public void prepare(ResponseBuilder rb) throws IOException {
  SolrParams params = rb.req.getParams();
  rb.doHighlights = highlighter.isHighlightingEnabled(params);
  if(rb.doHighlights){
    String hlq = params.get(HighlightParams.Q);
    String hlparser = Objects.firstNonNull(params.get(HighlightParams.QPARSER),
                                            params.get(QueryParsing.DEFTYPE, QParserPlugin.DEFAULT_QTYPE));
    if(hlq != null){
      try {
        QParser parser = QParser.getParser(hlq, hlparser, rb.req);
        rb.setHighlightQuery(parser.getHighlightQuery());
      } catch (SyntaxError e) {
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
      }
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:HighlightComponent.java

示例4: prepare

import org.apache.solr.search.QParser; //导入方法依赖的package包/类
@Override
public void prepare(ResponseBuilder rb) throws IOException {
  SolrParams params = rb.req.getParams();
  rb.doHighlights = highlighter.isHighlightingEnabled(params);
  if(rb.doHighlights){
    String hlq = params.get(HighlightParams.Q);
    if(hlq != null){
      try {
        QParser parser = QParser.getParser(hlq, null, rb.req);
        rb.setHighlightQuery(parser.getHighlightQuery());
      } catch (SyntaxError e) {
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
      }
    }
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:17,代码来源:HighlightComponent.java

示例5: parseFilters

import org.apache.solr.search.QParser; //导入方法依赖的package包/类
public static List<Query> parseFilters(Query q, SolrQueryRequest req) throws SyntaxError {
  List<Query> filters = null;
  filters = new ArrayList<Query>();
  if (q != null)
    filters.add(q);

  String[] fqs = req.getParams().getParams(CommonParams.FQ);
  if (fqs != null && fqs.length != 0) {
    for (String fq : fqs) {
      if (fq != null && fq.trim().length() != 0) {
        QParser fqp = QParser.getParser(fq, null, req);
        filters.add(fqp.getQuery());
      }
    }
  }

  return filters;
}
 
开发者ID:tballison,项目名称:lucene-addons,代码行数:19,代码来源:SolrConcordanceBase.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: 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

示例8: 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

示例9: qParser

import org.apache.solr.search.QParser; //导入方法依赖的package包/类
/**
 * Returns the {@link QParser} associated with this request.
 * 
 * @param request the {@link SolrQueryRequest}.
 * @return the {@link QParser} associated with this request.
 * @throws SyntaxError in case of syntax errors.
 */
QParser qParser(final SolrQueryRequest request) throws SyntaxError {
	return QParser.getParser(
			queryString(request), 
			DEFAULT_DEF_TYPE, 
			request);		
}
 
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:14,代码来源:SparqlSearchComponent.java

示例10: parser

import org.apache.solr.search.QParser; //导入方法依赖的package包/类
/**
 * @param query the query
 * @return a lucene qparser
 * @throws SyntaxError iff something goes wrong
 */
public QParser parser(String query) throws SyntaxError {
    return QParser.getParser(query, req);
}
 
开发者ID:ChronixDB,项目名称:chronix.server,代码行数:9,代码来源:ChronixCompactionHandler.java

示例11: setQuery

import org.apache.solr.search.QParser; //导入方法依赖的package包/类
/**
 * Sets the group query from the specified groupQueryString.
 * The groupQueryString is parsed into a query.
 *
 * @param groupQueryString The group query string to parse
 * @param request The current request
 * @return this
 */
public Builder setQuery(String groupQueryString, SolrQueryRequest request) throws SyntaxError {
  QParser parser = QParser.getParser(groupQueryString, null, request);
  this.queryString = groupQueryString;
  return setQuery(parser.getQuery());
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:QueryCommand.java


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