Package org.apache.lucene.queries.function

Examples of org.apache.lucene.queries.function.ValueSource


    IndexSearcher searcher = newSearcher(w.getReader());
   
    // NRT open
    TaxonomyReader tr = new DirectoryTaxonomyReader(tw);

    ValueSource values = new FloatFieldSource("value");

    int iters = atLeast(100);
    for(int iter=0;iter<iters;iter++) {
      String searchToken = tokens[random().nextInt(tokens.length)];
      if (VERBOSE) {
View Full Code Here


          fastMatchFilter = NumericRangeFilter.newFloatRange("field", minAcceptedValue, maxAcceptedValue, true, true);
        }
      } else {
        fastMatchFilter = null;
      }
      ValueSource vs = new FloatFieldSource("field");
      Facets facets = new DoubleRangeFacetCounts("field", vs, sfc, fastMatchFilter, ranges);
      FacetResult result = facets.getTopChildren(10, "field");
      assertEquals(numRange, result.labelValues.length);
      for(int rangeID=0;rangeID<numRange;rangeID++) {
        if (VERBOSE) {
View Full Code Here

          fastMatchFilter = NumericRangeFilter.newDoubleRange("field", minAcceptedValue, maxAcceptedValue, true, true);
        }
      } else {
        fastMatchFilter = null;
      }
      ValueSource vs = new DoubleFieldSource("field");
      Facets facets = new DoubleRangeFacetCounts("field", vs, sfc, fastMatchFilter, ranges);
      FacetResult result = facets.getTopChildren(10, "field");
      assertEquals(numRange, result.labelValues.length);
      for(int rangeID=0;rangeID<numRange;rangeID++) {
        if (VERBOSE) {
View Full Code Here

    writer.addDocument(doc);

    // Test wants 3 docs in one segment:
    writer.forceMerge(1);

    final ValueSource vs = new ValueSource() {
        @SuppressWarnings("rawtypes")
        @Override
        public FunctionValues getValues(Map ignored, AtomicReaderContext ignored2) {
          return new DoubleDocValues(null) {
            @Override
View Full Code Here

          fastMatchFilter = NumericRangeFilter.newLongRange("field", minAcceptedValue, maxAcceptedValue, true, true);
        }
      } else {
        fastMatchFilter = null;
      }
      ValueSource vs = new LongFieldSource("field");
      Facets facets = new LongRangeFacetCounts("field", vs, sfc, fastMatchFilter, ranges);
      FacetResult result = facets.getTopChildren(10, "field");
      assertEquals(numRange, result.labelValues.length);
      for(int rangeID=0;rangeID<numRange;rangeID++) {
        if (VERBOSE) {
View Full Code Here

  public TopDocs drillDown(DoubleRange range) throws IOException {

    // Passing no baseQuery means we drill down on all
    // documents ("browse only"):
    DrillDownQuery q = new DrillDownQuery(null);
    final ValueSource vs = getDistanceValueSource();
    q.add("field", range.getFilter(getBoundingBoxFilter(ORIGIN_LATITUDE, ORIGIN_LONGITUDE, range.max), vs));
    DrillSideways ds = new DrillSideways(searcher, config, (TaxonomyReader) null) {
        @Override
        protected Facets buildFacetsResult(FacetsCollector drillDowns, FacetsCollector[] drillSideways, String[] drillSidewaysDims) throws IOException {       
          assert drillSideways.length == 1;
View Full Code Here

    if (bbox.getCrossesDateLine()) {
      throw new UnsupportedOperationException( "Crossing dateline not yet supported" );
    }

    ValueSource valueSource = null;

    Query spatial = null;
    SpatialOperation op = args.getOperation();

    if( SpatialOperation.is( op,
View Full Code Here

 
  public void testTypes() throws Exception {
    Expression expr = JavascriptCompiler.compile("2*popularity");
    SimpleBindings bindings = new SimpleBindings();
    bindings.add(new SortField("popularity", SortField.Type.LONG));
    ValueSource vs = expr.getValueSource(bindings);
   
    assertEquals(1, reader.leaves().size());
    AtomicReaderContext leaf = reader.leaves().get(0);
    FunctionValues values = vs.getValues(new HashMap<String,Object>(), leaf);
   
    assertEquals(10, values.doubleVal(0), 0);
    assertEquals(10, values.floatVal(0), 0);
    assertEquals(10, values.longVal(0));
    assertEquals(10, values.intVal(0));
View Full Code Here

 
  public void testRangeScorer() throws Exception {
    Expression expr = JavascriptCompiler.compile("2*popularity");
    SimpleBindings bindings = new SimpleBindings();
    bindings.add(new SortField("popularity", SortField.Type.LONG));
    ValueSource vs = expr.getValueSource(bindings);
   
    assertEquals(1, reader.leaves().size());
    AtomicReaderContext leaf = reader.leaves().get(0);
    FunctionValues values = vs.getValues(new HashMap<String,Object>(), leaf);
   
    // everything
    ValueSourceScorer scorer = values.getRangeScorer(leaf.reader(), "4", "40", true, true);
    assertEquals(-1, scorer.docID());
    assertEquals(0, scorer.nextDoc());
View Full Code Here

   
    SimpleBindings bindings = new SimpleBindings();   
    bindings.add(new SortField("a", SortField.Type.INT));
    bindings.add(new SortField("b", SortField.Type.INT));
   
    ValueSource vs1 = expr.getValueSource(bindings);
    // same instance
    assertEquals(vs1, vs1);
    // null
    assertFalse(vs1.equals(null));
    // other object
    assertFalse(vs1.equals("foobar"));
    // same bindings and expression instances
    ValueSource vs2 = expr.getValueSource(bindings);
    assertEquals(vs1.hashCode(), vs2.hashCode());
    assertEquals(vs1, vs2);
    // equiv bindings (different instance)
    SimpleBindings bindings2 = new SimpleBindings();   
    bindings2.add(new SortField("a", SortField.Type.INT));
    bindings2.add(new SortField("b", SortField.Type.INT));
    ValueSource vs3 = expr.getValueSource(bindings2);
    assertEquals(vs1, vs3);
    // different bindings (same names, different types)
    SimpleBindings bindings3 = new SimpleBindings();   
    bindings3.add(new SortField("a", SortField.Type.LONG));
    bindings3.add(new SortField("b", SortField.Type.INT));
    ValueSource vs4 = expr.getValueSource(bindings3);
    assertFalse(vs1.equals(vs4));
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.queries.function.ValueSource

Copyright © 2018 www.massapicom. 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.