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


Java SyntaxError类代码示例

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


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

示例1: test_singleTerm

import org.apache.solr.search.SyntaxError; //导入依赖的package包/类
@Test
public void test_singleTerm() throws SyntaxError {

    // arrange
    QParser parser = new SimilarityParser("first",new ModifiableSolrParams(),mockCorrectParams,req("first"));

    // act
    Query luceneQuery = parser.parse();

    // assert
    AugmentedTermQuery expected = new AugmentedTermQuery(
            AugmentedTermQuery.ModelMethod.Generalized, new Term("text", "first"),
            new TermWeightTuple[]{SimilarityApiMock.similarTerm("text")}
            );

    Assert.assertEquals(expected, luceneQuery);
}
 
开发者ID:sebastian-hofstaetter,项目名称:ir-generalized-translation-models,代码行数:18,代码来源:SimilarityParserTest.java

示例2: getLuceneQuery

import org.apache.solr.search.SyntaxError; //导入依赖的package包/类
/**
 * Returns the Lucene query for the given locale and query text.
 * 
 * @param searchString
 *            the text query for the Lucene query parser
 * @param mId
 *            the marketplace id
 * @param locale
 *            the locale for the analyzer to use
 * @param isDefaultLocaleHandling
 * @return the Lucene query for the given locale and query text
 * @throws ParseException
 *             in case the query cannot be parsed
 */
private org.apache.lucene.search.Query getLuceneQuery(String searchString,
        String mId, String locale, boolean isDefaultLocaleHandling)
        throws SyntaxError, QueryNodeException {

    // construct wildcard query for the actual search part
    org.apache.lucene.search.Query textQuery = LuceneQueryBuilder
            .getServiceQuery(searchString, locale, DEFAULT_LOCALE,
                    isDefaultLocaleHandling);

    // build mId part
    TermQuery mIdQuery = new TermQuery(new Term(ProductClassBridge.MP_ID,
            QueryParser.escape(mId).toLowerCase()));

    // now construct final query
    BooleanQuery query = new BooleanQuery();
    query.add(mIdQuery, Occur.MUST);
    query.add(textQuery, Occur.MUST);
    return query;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:34,代码来源:SearchServiceBean.java

示例3: test

import org.apache.solr.search.SyntaxError; //导入依赖的package包/类
@Test
public void test() throws SyntaxError {

    HashMap<String, String> dateIntervals = new HashMap<>();
    dateIntervals.put("after","[NOW+23DAYS/DAY TO *]");
    dateIntervals.put("before","[* TO NOW+23DAYS/DAY]");

    HashMap<String, String> numberIntervals = new HashMap<>();
    numberIntervals.put("bigger","[23 TO *]");
    numberIntervals.put("smaller","[* TO 22]");

    SingleValueFieldDescriptor.UtilDateFieldDescriptor<Date> testDateField = new FieldDescriptorBuilder().buildUtilDateField("test1");
    FieldDescriptor<Float> testNumericField = new FieldDescriptorBuilder().buildNumericField("numericTest", Float.class);

    Assert.assertTrue(FacetMapper.stringQuery2FacetMapper(testDateField, "dateFacet",dateIntervals).getName().equals("dateFacet"));
    Assert.assertTrue(FacetMapper.stringQuery2FacetMapper(testNumericField, "numericFacet", numberIntervals).getName().equals("numericFacet"));

    Assert.assertTrue(true);
}
 
开发者ID:RBMHTechnology,项目名称:vind,代码行数:20,代码来源:FacetMapperTest.java

示例4: testComplexField

import org.apache.solr.search.SyntaxError; //导入依赖的package包/类
@Test
public void testComplexField() throws SyntaxError {

    HashMap<String, String> dateIntervals = new HashMap<>();
    dateIntervals.put("after","[NOW+23DAYS/DAY TO *]");
    dateIntervals.put("before","[* TO NOW+23DAYS/DAY]");

    HashMap<String, String> numberIntervals = new HashMap<>();
    numberIntervals.put("bigger","[23 TO *]");
    numberIntervals.put("smaller","[* TO 22]");

    SingleValuedComplexField.UtilDateComplexField<Taxonomy,Date,Date> complexDateField = new ComplexFieldDescriptorBuilder<Taxonomy,Date,Date>()
            .setFacet(true, tax -> Arrays.asList(tax.getDate()))
            .buildUtilDateComplexField("complexDateTax", Taxonomy.class, Date.class, Date.class);

    SingleValuedComplexField.NumericComplexField<Taxonomy,Number,Number> complexNumberField = new ComplexFieldDescriptorBuilder<Taxonomy,Number,Number>()
            .setFacet(true, tax -> Arrays.asList(tax.getTerm()))
            .buildNumericComplexField("complexNumberTax", Taxonomy.class, Number.class, Number.class);

    Assert.assertTrue(FacetMapper.stringQuery2FacetMapper(complexDateField, "dateFacet",dateIntervals).getName().equals("dateFacet"));
    Assert.assertTrue(FacetMapper.stringQuery2FacetMapper(complexNumberField, "numericFacet", numberIntervals).getName().equals("numericFacet"));

    Assert.assertTrue(true);
}
 
开发者ID:RBMHTechnology,项目名称:vind,代码行数:25,代码来源:FacetMapperTest.java

示例5: getFacetQueryCounts

import org.apache.solr.search.SyntaxError; //导入依赖的package包/类
/**
 * Returns a list of facet counts for each of the facet queries
 * specified in the params
 *
 * @see FacetParams#FACET_QUERY
 */
public NamedList<Integer> getFacetQueryCounts() throws IOException,SyntaxError {

  NamedList<Integer> res = new SimpleOrderedMap<>();

  /* Ignore CommonParams.DF - could have init param facet.query assuming
   * the schema default with query param DF intented to only affect Q.
   * If user doesn't want schema default for facet.query, they should be
   * explicit.
   */
  // SolrQueryParser qp = searcher.getSchema().getSolrQueryParser(null);

  String[] facetQs = global.getParams(FacetParams.FACET_QUERY);

  if (null != facetQs && 0 != facetQs.length) {
    for (String q : facetQs) {
      final ParsedParams parsed = parseParams(FacetParams.FACET_QUERY, q);
      getFacetQueryCount(parsed, res);
    }
  }

  return res;
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:29,代码来源:SimpleFacets.java

示例6: getHeatmapCounts

import org.apache.solr.search.SyntaxError; //导入依赖的package包/类
public NamedList getHeatmapCounts() throws IOException, SyntaxError {
  final NamedList<Object> resOuter = new SimpleOrderedMap<>();
  String[] unparsedFields = rb.req.getParams().getParams(FacetParams.FACET_HEATMAP);
  if (unparsedFields == null || unparsedFields.length == 0) {
    return resOuter;
  }
  if (global.getBool(GroupParams.GROUP_FACET, false)) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
        "Heatmaps can't be used with " + GroupParams.GROUP_FACET);
  }
  for (String unparsedField : unparsedFields) {
    final ParsedParams parsed = parseParams(FacetParams.FACET_HEATMAP, unparsedField); // populates facetValue, rb, params, docs

    resOuter.add(parsed.key, SpatialHeatmapFacets.getHeatmapForField(parsed.key, parsed.facetValue, rb, parsed.params, parsed.docs));
  }
  return resOuter;
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:18,代码来源:SimpleFacets.java

示例7: getLuceneQuery

import org.apache.solr.search.SyntaxError; //导入依赖的package包/类
/**
 * Returns the Lucene query for the given locale and query text.
 * 
 * @param searchString
 *            the text query for the Lucene query parser
 * @param mId
 *            the marketplace id
 * @param locale
 *            the locale for the analyzer to use
 * @param isDefaultLocaleHandling
 * @return the Lucene query for the given locale and query text
 * @throws ParseException
 *             in case the query cannot be parsed
 */
private org.apache.lucene.search.Query getLuceneQuery(String searchString,
        String mId, String locale,
        boolean isDefaultLocaleHandling) throws SyntaxError, QueryNodeException {

    // construct wildcard query for the actual search part
    org.apache.lucene.search.Query textQuery = LuceneQueryBuilder
            .getServiceQuery(searchString, locale, DEFAULT_LOCALE,
                    isDefaultLocaleHandling);

    // build mId part
    TermQuery mIdQuery = new TermQuery(new Term(ProductClassBridge.MP_ID,
            QueryParser.escape(mId).toLowerCase()));

    // now construct final query
    BooleanQuery query = new BooleanQuery();
    query.add(mIdQuery, Occur.MUST);
    query.add(textQuery, Occur.MUST);
    return query;
}
 
开发者ID:servicecatalog,项目名称:development,代码行数:34,代码来源:SearchServiceBean.java

示例8: doCompact

import org.apache.solr.search.SyntaxError; //导入依赖的package包/类
private void doCompact(LazyDocumentLoader documentLoader,
                       LazyCompactor compactor,
                       SolrQueryResponse rsp,
                       String tsId,
                       String q) throws IOException, SyntaxError {
    Query query = depProvider.parser(q).getQuery();

    Iterable<Document> docs = documentLoader.load(query, SORT);
    Iterable<CompactionResult> compactionResults = compactor.compact(docs);

    List<Document> docsToDelete = new LinkedList<>();
    List<SolrInputDocument> docsToAdd = new LinkedList<>();

    compactionResults.forEach(it -> {
        docsToDelete.addAll(it.getInputDocuments());
        docsToAdd.addAll(it.getOutputDocuments());
    });

    depProvider.solrUpdateService().add(docsToAdd);
    depProvider.solrUpdateService().delete(docsToDelete);

    rsp.add("timeseries " + tsId + " oldNumDocs:", docsToDelete.size());
    rsp.add("timeseries " + tsId + " newNumDocs:", docsToAdd.size());
}
 
开发者ID:ChronixDB,项目名称:chronix.server,代码行数:25,代码来源:ChronixCompactionHandler.java

示例9: olderDocumentsExists

import org.apache.solr.search.SyntaxError; //导入依赖的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

示例10: getFieldQuery

import org.apache.solr.search.SyntaxError; //导入依赖的package包/类
/**
 * Base implementation delegates to {@link #getFieldQuery(String,String,boolean)}.
 * This method may be overridden, for example, to return
 * a SpanNearQuery instead of a PhraseQuery.
 *
 */
protected Query getFieldQuery(String field, String queryText, int slop)
      throws SyntaxError {
  Query query = getFieldQuery(field, queryText, true);

  // only set slop of the phrase query was a result of this parser
  // and not a sub-parser.
  if (subQParser == null) {

    if (query instanceof PhraseQuery) {
      ((PhraseQuery) query).setSlop(slop);
    }
    if (query instanceof MultiPhraseQuery) {
      ((MultiPhraseQuery) query).setSlop(slop);
    }

  }

  return query;
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:SolrQueryParserBase.java

示例11: getFacetDateCounts

import org.apache.solr.search.SyntaxError; //导入依赖的package包/类
/**
 * Returns a list of value constraints and the associated facet counts 
 * for each facet date field, range, and interval specified in the
 * SolrParams
 *
 * @see FacetParams#FACET_DATE
 * @deprecated Use getFacetRangeCounts which is more generalized
 */
@Deprecated
public NamedList<Object> getFacetDateCounts()
  throws IOException, SyntaxError {

  final NamedList<Object> resOuter = new SimpleOrderedMap<>();
  final String[] fields = params.getParams(FacetParams.FACET_DATE);

  if (null == fields || 0 == fields.length) return resOuter;

  for (String f : fields) {
    getFacetDateCounts(f, resOuter);
  }

  return resOuter;
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:SimpleFacets.java

示例12: unescape

import org.apache.solr.search.SyntaxError; //导入依赖的package包/类
private int unescape(String s, int i, int n, StringBuilder sb) throws SyntaxError {
  for (; i < n; ++i) {
    char c = s.charAt(i);
    if (c == '\\') {
      ++i;
      if (i < n) {
        c = s.charAt(i);
      } else {
        throw new SyntaxError("Unfinished escape at index " + i + " in facet interval " + s);
      }
    } else if (c == ',') {
      return i + 1;
    }
    sb.append(c);
  }
  return n;
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:IntervalFacets.java

示例13: getQuery

import org.apache.solr.search.SyntaxError; //导入依赖的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

示例14: parse

import org.apache.solr.search.SyntaxError; //导入依赖的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

示例15: FacetBase

import org.apache.solr.search.SyntaxError; //导入依赖的package包/类
public FacetBase(ResponseBuilder rb, String facetType, String facetStr) {
  this.facetType = facetType;
  this.facetStr = facetStr;
  try {
    this.localParams = QueryParsing.getLocalParams(facetStr,
                                                   rb.req.getParams());
  } catch (SyntaxError e) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
  }
  this.facetOn = facetStr;
  this.key = facetStr;
  
  if (localParams != null) {
    // remove local params unless it's a query
    if (!facetType.equals(FacetParams.FACET_QUERY)) {
      facetOn = localParams.get(CommonParams.VALUE);
      key = facetOn;
    }
    
    key = localParams.get(CommonParams.OUTPUT_KEY, key);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:FacetComponent.java


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