Java Code Examples for org.apache.lucene.search.DoubleValuesSource#fromDoubleField()
The following examples show how to use
org.apache.lucene.search.DoubleValuesSource#fromDoubleField() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestFunctionScoreQuery.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testNaN() throws IOException { Directory dir = newDirectory(); IndexWriter w = new IndexWriter(dir, newIndexWriterConfig()); Document doc = new Document(); doc.add(new NumericDocValuesField("foo", Double.doubleToLongBits(Double.NaN))); w.addDocument(doc); IndexReader reader = DirectoryReader.open(w); w.close(); IndexSearcher searcher = newSearcher(reader); Query q = new FunctionScoreQuery(new MatchAllDocsQuery(), DoubleValuesSource.fromDoubleField("foo")); QueryUtils.check(random(), q, searcher); Explanation expl = searcher.explain(q, 0); assertEquals(0, expl.getValue().doubleValue(), 0f); assertTrue(expl.toString(), expl.getDetails()[0].getDescription().contains("NaN is an illegal score")); reader.close(); dir.close(); }
Example 2
Source File: TestExpressionSorts.java From lucene-solr with Apache License 2.0 | 6 votes |
private DoubleValuesSource fromSortField(SortField field) { switch(field.getType()) { case INT: return DoubleValuesSource.fromIntField(field.getField()); case LONG: return DoubleValuesSource.fromLongField(field.getField()); case FLOAT: return DoubleValuesSource.fromFloatField(field.getField()); case DOUBLE: return DoubleValuesSource.fromDoubleField(field.getField()); case SCORE: return DoubleValuesSource.SCORES; default: throw new UnsupportedOperationException(); } }
Example 3
Source File: DocumentExpressionDictionaryFactory.java From lucene-solr with Apache License 2.0 | 6 votes |
private DoubleValuesSource fromSortField(SortField field) { switch(field.getType()) { case INT: return DoubleValuesSource.fromIntField(field.getField()); case LONG: return DoubleValuesSource.fromLongField(field.getField()); case FLOAT: return DoubleValuesSource.fromFloatField(field.getField()); case DOUBLE: return DoubleValuesSource.fromDoubleField(field.getField()); case SCORE: return DoubleValuesSource.SCORES; default: throw new UnsupportedOperationException(); } }
Example 4
Source File: WrappedIntPointField.java From lucene-solr with Apache License 2.0 | 6 votes |
private static DoubleValuesSource fromSortField(SortField field) { switch(field.getType()) { case INT: return DoubleValuesSource.fromIntField(field.getField()); case LONG: return DoubleValuesSource.fromLongField(field.getField()); case FLOAT: return DoubleValuesSource.fromFloatField(field.getField()); case DOUBLE: return DoubleValuesSource.fromDoubleField(field.getField()); case SCORE: return DoubleValuesSource.SCORES; default: throw new UnsupportedOperationException(); } }
Example 5
Source File: DoubleRangeGroupSelectorTest.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override protected GroupSelector<DoubleRange> getGroupSelector() { return new DoubleRangeGroupSelector(DoubleValuesSource.fromDoubleField("double"), new DoubleRangeFactory(100, 100, 900)); }
Example 6
Source File: DoubleRangeFacetCounts.java From lucene-solr with Apache License 2.0 | 2 votes |
/** * Create {@code RangeFacetCounts}, using {@link DoubleValues} from the specified field. * * N.B This assumes that the field was indexed with {@link org.apache.lucene.document.DoubleDocValuesField}. * For float-valued fields, use {@link #DoubleRangeFacetCounts(String, DoubleValuesSource, FacetsCollector, DoubleRange...)} */ public DoubleRangeFacetCounts(String field, FacetsCollector hits, DoubleRange... ranges) throws IOException { this(field, DoubleValuesSource.fromDoubleField(field), hits, ranges); }