Package org.apache.lucene.queries.function.valuesource

Examples of org.apache.lucene.queries.function.valuesource.DoubleConstValueSource


        new DocFreqValueSource("bogus", "bogus", "text", new BytesRef("test"))),
        new float[] { 2f, 2f });
  }
 
  public void testDoubleConst() throws Exception {
    assertHits(new FunctionQuery(new DoubleConstValueSource(0.3d)),
        new float[] { 0.3f, 0.3f });
  }
View Full Code Here


    // Make sure the index is created?
    RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc);
    writer.commit();
    writer.close();
    IndexReader ir = DirectoryReader.open(dir);
    Dictionary dictionary = new DocumentValueSourceDictionary(ir, FIELD_NAME,  new DoubleConstValueSource(10), PAYLOAD_FIELD_NAME);
    InputIterator inputIterator = (InputIterator) dictionary.getEntryIterator();

    assertNull(inputIterator.next());
    assertEquals(inputIterator.weight(), 0);
    assertNull(inputIterator.payload());
View Full Code Here

    }
    writer.commit();
    writer.close();

    IndexReader ir = DirectoryReader.open(dir);
    Dictionary dictionary = new DocumentValueSourceDictionary(ir, FIELD_NAME, new DoubleConstValueSource(10), PAYLOAD_FIELD_NAME);
    InputIterator inputIterator = (InputIterator) dictionary.getEntryIterator();
    BytesRef f;
    while((f = inputIterator.next())!=null) {
      Document doc = docs.remove(f.utf8ToString());
      assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
View Full Code Here

        new DocFreqValueSource("bogus", "bogus", "text", new BytesRef("test"))),
        new float[] { 2f, 2f });
  }
 
  public void testDoubleConst() throws Exception {
    assertHits(new FunctionQuery(new DoubleConstValueSource(0.3d)),
        new float[] { 0.3f, 0.3f });
  }
View Full Code Here

    // Make sure the index is created?
    RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc);
    writer.commit();
    writer.close();
    IndexReader ir = DirectoryReader.open(dir);
    Dictionary dictionary = new DocumentValueSourceDictionary(ir, FIELD_NAME,  new DoubleConstValueSource(10), PAYLOAD_FIELD_NAME);
    InputIterator inputIterator = dictionary.getEntryIterator();

    assertNull(inputIterator.next());
    assertEquals(inputIterator.weight(), 0);
    assertNull(inputIterator.payload());
View Full Code Here

    }
    writer.commit();
    writer.close();

    IndexReader ir = DirectoryReader.open(dir);
    Dictionary dictionary = new DocumentValueSourceDictionary(ir, FIELD_NAME, new DoubleConstValueSource(10), PAYLOAD_FIELD_NAME);
    InputIterator inputIterator = dictionary.getEntryIterator();
    BytesRef f;
    while((f = inputIterator.next())!=null) {
      Document doc = docs.remove(f.utf8ToString());
      assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
View Full Code Here

                // TODO: document and/or error if vars contains _score?
                // NOTE: by checking for the variable in vars first, it allows masking document fields with a global constant,
                // but if we were to reverse it, we could provide a way to supply dynamic defaults for documents missing the field?
                Object value = vars.get(variable);
                if (value instanceof Number) {
                    bindings.add(variable, new DoubleConstValueSource(((Number)value).doubleValue()));
                } else {
                    throw new ExpressionScriptCompilationException("Parameter [" + variable + "] must be a numeric type");
                }

            } else {
View Full Code Here

TOP

Related Classes of org.apache.lucene.queries.function.valuesource.DoubleConstValueSource

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.