Search in sources :

Example 1 with FieldValueQuery

use of org.apache.lucene.search.FieldValueQuery in project elasticsearch by elastic.

the class MaxAggregatorTests method testSomeMatchesSortedNumericDocValues.

public void testSomeMatchesSortedNumericDocValues() throws IOException {
    testCase(new FieldValueQuery("number"), iw -> {
        iw.addDocument(singleton(new SortedNumericDocValuesField("number", 7)));
        iw.addDocument(singleton(new SortedNumericDocValuesField("number", 1)));
    }, max -> {
        assertEquals(7, max.getValue(), 0);
    });
}
Also used : SortedNumericDocValuesField(org.apache.lucene.document.SortedNumericDocValuesField) FieldValueQuery(org.apache.lucene.search.FieldValueQuery)

Example 2 with FieldValueQuery

use of org.apache.lucene.search.FieldValueQuery in project elasticsearch by elastic.

the class AvgAggregatorTests method testSomeMatchesSortedNumericDocValues.

public void testSomeMatchesSortedNumericDocValues() throws IOException {
    testCase(new FieldValueQuery("number"), iw -> {
        iw.addDocument(singleton(new SortedNumericDocValuesField("number", 7)));
        iw.addDocument(singleton(new SortedNumericDocValuesField("number", 2)));
        iw.addDocument(singleton(new SortedNumericDocValuesField("number", 3)));
    }, avg -> {
        assertEquals(4, avg.getValue(), 0);
    });
}
Also used : SortedNumericDocValuesField(org.apache.lucene.document.SortedNumericDocValuesField) FieldValueQuery(org.apache.lucene.search.FieldValueQuery)

Example 3 with FieldValueQuery

use of org.apache.lucene.search.FieldValueQuery in project elasticsearch by elastic.

the class ValueCountAggregatorTests method testSomeMatchesSortedNumericDocValues.

public void testSomeMatchesSortedNumericDocValues() throws IOException {
    testCase(new FieldValueQuery(FIELD_NAME), ValueType.NUMERIC, iw -> {
        iw.addDocument(singleton(new SortedNumericDocValuesField("wrong_number", 7)));
        iw.addDocument(singleton(new SortedNumericDocValuesField(FIELD_NAME, 7)));
        iw.addDocument(singleton(new SortedNumericDocValuesField(FIELD_NAME, 1)));
    }, count -> assertEquals(2L, count.getValue()));
}
Also used : SortedNumericDocValuesField(org.apache.lucene.document.SortedNumericDocValuesField) FieldValueQuery(org.apache.lucene.search.FieldValueQuery)

Example 4 with FieldValueQuery

use of org.apache.lucene.search.FieldValueQuery in project elasticsearch by elastic.

the class SumAggregatorTests method testSortedNumericDocValues.

public void testSortedNumericDocValues() throws IOException {
    testCase(new FieldValueQuery(FIELD_NAME), iw -> {
        iw.addDocument(Arrays.asList(new SortedNumericDocValuesField(FIELD_NAME, 3), new SortedNumericDocValuesField(FIELD_NAME, 4)));
        iw.addDocument(Arrays.asList(new SortedNumericDocValuesField(FIELD_NAME, 3), new SortedNumericDocValuesField(FIELD_NAME, 4)));
        iw.addDocument(singleton(new SortedNumericDocValuesField(FIELD_NAME, 1)));
    }, count -> assertEquals(15L, count.getValue(), 0d));
}
Also used : SortedNumericDocValuesField(org.apache.lucene.document.SortedNumericDocValuesField) FieldValueQuery(org.apache.lucene.search.FieldValueQuery)

Example 5 with FieldValueQuery

use of org.apache.lucene.search.FieldValueQuery in project elasticsearch by elastic.

the class AvgAggregatorTests method testSomeMatchesNumericDocValues.

public void testSomeMatchesNumericDocValues() throws IOException {
    testCase(new FieldValueQuery("number"), iw -> {
        iw.addDocument(singleton(new NumericDocValuesField("number", 7)));
        iw.addDocument(singleton(new NumericDocValuesField("number", 2)));
        iw.addDocument(singleton(new NumericDocValuesField("number", 3)));
    }, avg -> {
        assertEquals(4, avg.getValue(), 0);
    });
}
Also used : NumericDocValuesField(org.apache.lucene.document.NumericDocValuesField) SortedNumericDocValuesField(org.apache.lucene.document.SortedNumericDocValuesField) FieldValueQuery(org.apache.lucene.search.FieldValueQuery)

Aggregations

FieldValueQuery (org.apache.lucene.search.FieldValueQuery)9 SortedNumericDocValuesField (org.apache.lucene.document.SortedNumericDocValuesField)7 NumericDocValuesField (org.apache.lucene.document.NumericDocValuesField)3 BooleanQuery (org.apache.lucene.search.BooleanQuery)2 EnumSet (java.util.EnumSet)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 SortedSet (java.util.SortedSet)1 TreeSet (java.util.TreeSet)1 LeafReaderContext (org.apache.lucene.index.LeafReaderContext)1 NumericDocValues (org.apache.lucene.index.NumericDocValues)1 FilterScorer (org.apache.lucene.search.FilterScorer)1 IndexSearcher (org.apache.lucene.search.IndexSearcher)1 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)1 MatchNoDocsQuery (org.apache.lucene.search.MatchNoDocsQuery)1 Query (org.apache.lucene.search.Query)1 Scorer (org.apache.lucene.search.Scorer)1 TermQuery (org.apache.lucene.search.TermQuery)1 Weight (org.apache.lucene.search.Weight)1 BitSet (org.apache.lucene.util.BitSet)1