Java 类org.apache.lucene.document.FloatField 实例源码

项目:LuceneDB    文件:LuceneObjectValuesDB.java   
/**
 * resolve field convertable premitive type
 *
 * premitive type
 * byte, short, int, long, float, double, char, boolean
 *
 * @param type field type
 * @return lucene field type
 */
private Class<? extends Field> resolveField(Type type) {
    if(type == String.class) {
        return StringField.class;
    } else if (type == Double.class || type == double.class) {
        return DoubleField.class;
    } else if(type == Float.class || type == float.class) {
        return FloatField.class;
    } else if(type == Integer.class || type == int.class ||
            type == Short.class || type == short.class ||
            type == Boolean.class || type == boolean.class ||
            type == Byte.class || type == byte.class ||
            type == Character.class || type == char.class) {
        return IntField.class;
    } else if(type == Long.class || type == long.class) {
        return LongField.class;
    }
    return null;
}
项目:LuceneDB    文件:UserDefineDocumentCreatorTest.java   
@Test
public void simpleTest() throws IOException {
    LuceneValuesDB valuesDB = new LuceneValuesDB();
    URL testPath = LuceneValuesDB.class.getResource("test.csv");

    @SuppressWarnings("unchecked")
    UserDefineDocumentCreator creator = new UserDefineDocumentCreator(new Class[] {
            IntField.class,
            StringField.class,
            FloatField.class,
            TextField.class
    }, new String[] {
            "docNum",
            "docType",
            "score",
            "text"
    });

    valuesDB.open(new File(testPath.getFile()), new CSVParser(), creator);

    assertEquals(1, valuesDB.search("docNum", 0).length);
    assertEquals(1, valuesDB.search("docType", "a").length);
    assertEquals(2, valuesDB.search("score", "0.1").length);
    assertEquals(1, valuesDB.search("text", "this is a pen").length);
}
项目:search    文件:TestExpressionSorts.java   
@Override
public void setUp() throws Exception {
  super.setUp();
  dir = newDirectory();
  RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
  int numDocs = TestUtil.nextInt(random(), 2049, 4000);
  for (int i = 0; i < numDocs; i++) {
    Document document = new Document();
    document.add(newTextField("english", English.intToEnglish(i), Field.Store.NO));
    document.add(newTextField("oddeven", (i % 2 == 0) ? "even" : "odd", Field.Store.NO));
    document.add(newStringField("byte", "" + ((byte) random().nextInt()), Field.Store.NO));
    document.add(newStringField("short", "" + ((short) random().nextInt()), Field.Store.NO));
    document.add(new IntField("int", random().nextInt(), Field.Store.NO));
    document.add(new LongField("long", random().nextLong(), Field.Store.NO));

    document.add(new FloatField("float", random().nextFloat(), Field.Store.NO));
    document.add(new DoubleField("double", random().nextDouble(), Field.Store.NO));

    document.add(new NumericDocValuesField("intdocvalues", random().nextInt()));
    document.add(new FloatDocValuesField("floatdocvalues", random().nextFloat()));
    iw.addDocument(document);
  }
  reader = iw.getReader();
  iw.close();
  searcher = newSearcher(reader);
}
项目:search    文件:TestTerms.java   
public void testFloatFieldMinMax() throws Exception {
  Directory dir = newDirectory();
  RandomIndexWriter w = new RandomIndexWriter(random(), dir);
  int numDocs = atLeast(100);
  float minValue = Float.POSITIVE_INFINITY;
  float maxValue = Float.NEGATIVE_INFINITY;
  for(int i=0;i<numDocs;i++ ){
    Document doc = new Document();
    float num = random().nextFloat();
    minValue = Math.min(num, minValue);
    maxValue = Math.max(num, maxValue);
    doc.add(new FloatField("field", num, Field.Store.NO));
    w.addDocument(doc);
  }

  IndexReader r = w.getReader();
  Terms terms = MultiFields.getTerms(r, "field");
  assertEquals(minValue, NumericUtils.sortableIntToFloat(NumericUtils.getMinInt(terms)), 0.0f);
  assertEquals(maxValue, NumericUtils.sortableIntToFloat(NumericUtils.getMaxInt(terms)), 0.0f);

  r.close();
  w.close();
  dir.close();
}
项目:incubator-blur    文件:FloatFieldTypeDefinition.java   
@Override
public void configure(String fieldNameForThisInstance, Map<String, String> properties, Configuration configuration) {
  String precisionStepStr = properties.get(NUMERIC_PRECISION_STEP);
  if (precisionStepStr != null) {
    _precisionStep = Integer.parseInt(precisionStepStr);
    _typeStored = new FieldType(FloatField.TYPE_STORED);
    _typeStored.setNumericPrecisionStep(_precisionStep);
    _typeStored.freeze();
    _typeNotStored = new FieldType(FloatField.TYPE_NOT_STORED);
    _typeNotStored.setNumericPrecisionStep(_precisionStep);
    _typeNotStored.freeze();
  } else {
    _typeStored = FloatField.TYPE_STORED;
    _typeNotStored = FloatField.TYPE_NOT_STORED;
  }
}
项目:Maskana-Gestor-de-Conocimiento    文件:TestExpressionSorts.java   
@Override
public void setUp() throws Exception {
  super.setUp();
  dir = newDirectory();
  RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
  int numDocs = _TestUtil.nextInt(random(), 2049, 4000);
  for (int i = 0; i < numDocs; i++) {
    Document document = new Document();
    document.add(newTextField("english", English.intToEnglish(i), Field.Store.NO));
    document.add(newTextField("oddeven", (i % 2 == 0) ? "even" : "odd", Field.Store.NO));
    document.add(newStringField("byte", "" + ((byte) random().nextInt()), Field.Store.NO));
    document.add(newStringField("short", "" + ((short) random().nextInt()), Field.Store.NO));
    document.add(new IntField("int", random().nextInt(), Field.Store.NO));
    document.add(new LongField("long", random().nextLong(), Field.Store.NO));

    document.add(new FloatField("float", random().nextFloat(), Field.Store.NO));
    document.add(new DoubleField("double", random().nextDouble(), Field.Store.NO));

    document.add(new NumericDocValuesField("intdocvalues", random().nextInt()));
    document.add(new FloatDocValuesField("floatdocvalues", random().nextFloat()));
    iw.addDocument(document);
  }
  reader = iw.getReader();
  iw.close();
  searcher = newSearcher(reader);
}
项目:sql-layer    文件:IndexedField.java   
public Field getField(ValueSource value) {
    if (value.isNull()) 
        return null;
    Field.Store store = Field.Store.NO; // Only store hkey.
    switch (fieldType) {
    case INT:
        switch (TInstance.underlyingType(value.getType())) {
        case INT_8:
            return new IntField(name, value.getInt8(), store);
        case INT_16:
            return new IntField(name, value.getInt16(), store);
        case UINT_16:
            return new IntField(name, value.getUInt16(), store);
        case INT_32:
        default:
            return new IntField(name, value.getInt32(), store);
        }
    case LONG:
        return new LongField(name, value.getInt64(), store);
    case FLOAT:
        return new FloatField(name, value.getFloat(), store);
    case DOUBLE:
        return new DoubleField(name, value.getDouble(), store);
    case STRING:
        switch (TInstance.underlyingType(value.getType())) {
        case STRING:
            return new StringField(name, value.getString(), store);
        default:
            {
                StringBuilder str = new StringBuilder();
                value.getType().format(value, AkibanAppender.of(str));
                return new StringField(name, str.toString(), store);
            }
        }
    case TEXT:
        return new TextField(name, value.getString(), store);
    default:
        return null;
    }
}
项目:LuceneDB    文件:LuceneObjectValuesDB.java   
/**
 * add lucene field in document
 * @param doc document
 * @param name fieldName
 * @param val value
 * @param type field original Type
 * @param store store
 * @param textFieldable isTextField
 * @return if true, added document
 */
private boolean addField(Document doc, String name, Object val, Type type, Store store, TextFieldable textFieldable, NoIndex noIndex) {
    boolean add = true;
    if (noIndex != null) {
        if (type == Character.class || type == char.class) {
            val = (int) val;
        } else if(type == Boolean.class || type == boolean.class) {
            val = (boolean)val ? 1 : 0;
        }
        doc.add(new StoredField(name, val.toString()));
    } else if (textFieldable != null) {
        doc.add(new TextField(name, val.toString(), store));
    } else if(type == String.class) {
        doc.add(new StringField(name, val.toString(), store));
    }else if (type == Double.class || type == double.class) {
        doc.add(new DoubleField(name, (double) val, store));
    } else if(type == Float.class || type == float.class) {
        doc.add(new FloatField(name, (float) val, store));
    } else if(type == Short.class || type == short.class ||
            type == Integer.class || type == int.class ||
            type == Byte.class || type == byte.class) {
        doc.add(new IntField(name, Integer.valueOf(val.toString()), store));
    } else if(type == Character.class || type == char.class) {
        doc.add(new IntField(name, Integer.valueOf((char)val), store));
    } else if(type == Boolean.class || type == boolean.class) {
        if ((boolean)val) {
            doc.add(new IntField(name, 1, store));
        } else {
            doc.add(new IntField(name, 0, store));
        }
    } else if(type == Long.class || type == long.class) {
        doc.add(new LongField(name, (long) val, store));
    } else {
        add = false;
    }
    return add;
}
项目:search    文件:ReadTokensTask.java   
@Override
public int doLogic() throws Exception {
  List<IndexableField> fields = doc.getFields();
  Analyzer analyzer = getRunData().getAnalyzer();
  int tokenCount = 0;
  for(final IndexableField field : fields) {
    if (!field.fieldType().tokenized() ||
        field instanceof IntField ||
        field instanceof LongField ||
        field instanceof FloatField ||
        field instanceof DoubleField) {
      continue;
    }

    final TokenStream stream = field.tokenStream(analyzer, null);
    // reset the TokenStream to the first token
    stream.reset();

    TermToBytesRefAttribute termAtt = stream.getAttribute(TermToBytesRefAttribute.class);
    while(stream.incrementToken()) {
      termAtt.fillBytesRef();
      tokenCount++;
    }
    stream.end();
    stream.close();
  }
  totalTokenCount += tokenCount;
  return tokenCount;
}
项目:search    文件:SolrIndexSearcher.java   
@Override
public void floatField(FieldInfo fieldInfo, float value) {
  FieldType ft = new FieldType(FloatField.TYPE_NOT_STORED);
  ft.setStored(true);
  ft.setIndexed(fieldInfo.isIndexed());
  doc.add(new FloatField(fieldInfo.name, value, ft));
}
项目:mgraph-summarization    文件:LuceneTextIndex.java   
public List<Document> searchDocuments(String text) {
    List<Document> documents = new ArrayList<Document>();
    try {
        TokenStream tokenStream = analyzer.tokenStream("text", text);
        CharTermAttribute charTermAtt = tokenStream.addAttribute(CharTermAttribute.class);
        tokenStream.reset();
        BooleanQuery bQuery = new BooleanQuery();
        while (tokenStream.incrementToken()) {
            String token = charTermAtt.toString();
            TermQuery tq = new TermQuery(new Term("text", token));
            tq.setBoost(2f);

            bQuery.add(tq, Occur.MUST);
        }
        tokenStream.close();

        TopDocs results = searcher.search(bQuery, 100000);
        ScoreDoc[] hits = results.scoreDocs;
        for(ScoreDoc hit : hits) {              
            Document doc = searcher.doc(hit.doc);
            doc.add(new FloatField("score", hit.score, FloatField.TYPE_STORED));
            documents.add(doc);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return documents;
}
项目:NYBC    文件:ReadTokensTask.java   
@Override
public int doLogic() throws Exception {
  List<IndexableField> fields = doc.getFields();
  Analyzer analyzer = getRunData().getAnalyzer();
  int tokenCount = 0;
  for(final IndexableField field : fields) {
    if (!field.fieldType().tokenized() ||
        field instanceof IntField ||
        field instanceof LongField ||
        field instanceof FloatField ||
        field instanceof DoubleField) {
      continue;
    }

    final TokenStream stream = field.tokenStream(analyzer);
    // reset the TokenStream to the first token
    stream.reset();

    TermToBytesRefAttribute termAtt = stream.getAttribute(TermToBytesRefAttribute.class);
    while(stream.incrementToken()) {
      termAtt.fillBytesRef();
      tokenCount++;
    }
  }
  totalTokenCount += tokenCount;
  return tokenCount;
}
项目:NYBC    文件:TestSearchAfter.java   
@Override
public void setUp() throws Exception {
  super.setUp();
  dir = newDirectory();
  RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
  int numDocs = atLeast(200);
  for (int i = 0; i < numDocs; i++) {
    Document document = new Document();
    document.add(newTextField("english", English.intToEnglish(i), Field.Store.NO));
    document.add(newTextField("oddeven", (i % 2 == 0) ? "even" : "odd", Field.Store.NO));
    document.add(newStringField("byte", "" + ((byte) random().nextInt()), Field.Store.NO));
    document.add(newStringField("short", "" + ((short) random().nextInt()), Field.Store.NO));
    document.add(new IntField("int", random().nextInt(), Field.Store.NO));
    document.add(new LongField("long", random().nextLong(), Field.Store.NO));

    document.add(new FloatField("float", random().nextFloat(), Field.Store.NO));
    document.add(new DoubleField("double", random().nextDouble(), Field.Store.NO));
    document.add(newStringField("bytes", _TestUtil.randomRealisticUnicodeString(random()), Field.Store.NO));
    document.add(newStringField("bytesval", _TestUtil.randomRealisticUnicodeString(random()), Field.Store.NO));
    document.add(new DoubleField("double", random().nextDouble(), Field.Store.NO));

    if (supportsDocValues) {
      document.add(new NumericDocValuesField("intdocvalues", random().nextInt()));
      document.add(new FloatDocValuesField("floatdocvalues", random().nextFloat()));
      document.add(new SortedDocValuesField("sortedbytesdocvalues", new BytesRef(_TestUtil.randomRealisticUnicodeString(random()))));
      document.add(new SortedDocValuesField("sortedbytesdocvaluesval", new BytesRef(_TestUtil.randomRealisticUnicodeString(random()))));
      document.add(new BinaryDocValuesField("straightbytesdocvalues", new BytesRef(_TestUtil.randomRealisticUnicodeString(random()))));
    }
    iw.addDocument(document);
  }
  reader = iw.getReader();
  iw.close();
  searcher = newSearcher(reader);
}
项目:NYBC    文件:SolrIndexSearcher.java   
@Override
public void floatField(FieldInfo fieldInfo, float value) {
  FieldType ft = new FieldType(FloatField.TYPE_NOT_STORED);
  ft.setStored(true);
  ft.setIndexed(fieldInfo.isIndexed());
  doc.add(new FloatField(fieldInfo.name, value, ft));
}
项目:incubator-blur    文件:FloatFieldTypeDefinition.java   
@Override
public Iterable<? extends Field> getFieldsForColumn(String family, Column column) {
  String name = getName(family, column.getName());
  float value = Float.parseFloat(column.getValue());
  FloatField field = new FloatField(name, value, _typeStored);
  if (isSortEnable()) {
    return addSort(name, Float.floatToRawIntBits(value), field);
  }
  return makeIterable(field);
}
项目:incubator-blur    文件:FloatFieldTypeDefinition.java   
@Override
public Iterable<? extends Field> getFieldsForSubColumn(String family, Column column, String subName) {
  String name = getName(family, column.getName(), subName);
  float value = Float.parseFloat(column.getValue());
  FloatField field = new FloatField(name, value, _typeNotStored);
  if (isSortEnable()) {
    return addSort(name, Float.floatToRawIntBits(value), field);
  }
  return makeIterable(field);
}
项目:search-core    文件:SolrIndexSearcher.java   
@Override
public void floatField(FieldInfo fieldInfo, float value) {
    FieldType ft = new FieldType(FloatField.TYPE_NOT_STORED);
    ft.setStored(true);
    ft.setIndexed(fieldInfo.isIndexed());
    doc.add(new FloatField(fieldInfo.name, value, ft));
}
项目:read-open-source-code    文件:ReadTokensTask.java   
@Override
public int doLogic() throws Exception {
  List<IndexableField> fields = doc.getFields();
  Analyzer analyzer = getRunData().getAnalyzer();
  int tokenCount = 0;
  for(final IndexableField field : fields) {
    if (!field.fieldType().tokenized() ||
        field instanceof IntField ||
        field instanceof LongField ||
        field instanceof FloatField ||
        field instanceof DoubleField) {
      continue;
    }

    final TokenStream stream = field.tokenStream(analyzer);
    // reset the TokenStream to the first token
    stream.reset();

    TermToBytesRefAttribute termAtt = stream.getAttribute(TermToBytesRefAttribute.class);
    while(stream.incrementToken()) {
      termAtt.fillBytesRef();
      tokenCount++;
    }
    stream.end();
    stream.close();
  }
  totalTokenCount += tokenCount;
  return tokenCount;
}
项目:read-open-source-code    文件:SolrIndexSearcher.java   
@Override
public void floatField(FieldInfo fieldInfo, float value) {
  FieldType ft = new FieldType(FloatField.TYPE_NOT_STORED);
  ft.setStored(true);
  ft.setIndexed(fieldInfo.isIndexed());
  doc.add(new FloatField(fieldInfo.name, value, ft));
}
项目:read-open-source-code    文件:ReadTokensTask.java   
@Override
public int doLogic() throws Exception {
  List<IndexableField> fields = doc.getFields();
  Analyzer analyzer = getRunData().getAnalyzer();
  int tokenCount = 0;
  for(final IndexableField field : fields) {
    if (!field.fieldType().tokenized() ||
        field instanceof IntField ||
        field instanceof LongField ||
        field instanceof FloatField ||
        field instanceof DoubleField) {
      continue;
    }

    final TokenStream stream = field.tokenStream(analyzer);
    // reset the TokenStream to the first token
    stream.reset();

    TermToBytesRefAttribute termAtt = stream.getAttribute(TermToBytesRefAttribute.class);
    while(stream.incrementToken()) {
      termAtt.fillBytesRef();
      tokenCount++;
    }
    stream.end();
    stream.close();
  }
  totalTokenCount += tokenCount;
  return tokenCount;
}
项目:read-open-source-code    文件:SolrIndexSearcher.java   
@Override
public void floatField(FieldInfo fieldInfo, float value) {
  FieldType ft = new FieldType(FloatField.TYPE_NOT_STORED);
  ft.setStored(true);
  ft.setIndexed(fieldInfo.isIndexed());
  doc.add(new FloatField(fieldInfo.name, value, ft));
}
项目:esa-pfa    文件:DsIndexer.java   
public void addPatchToIndex(String productName, int patchX, int patchY, Properties featureValues) throws IOException {

        Document doc = new Document();
        doc.add(new LongField("id", docID, storedLongType));
        doc.add(new TextField("product", productName, Field.Store.YES));
        doc.add(new IntField("px", patchX, storedIntType));
        doc.add(new IntField("py", patchY, storedIntType));
        // 'rnd' is for selecting random subsets
        doc.add(new DoubleField("rnd", Math.random(), unstoredDoubleType));

        // todo - put useful values into 'lat', 'lon', 'time'
        doc.add(new FloatField("lat", -90 + 180 * (float) Math.random(), unstoredFloatType));
        doc.add(new FloatField("lon", -180 + 360 * (float) Math.random(), unstoredFloatType));
        doc.add(new LongField("time", docID, unstoredLongType));

        for (FeatureFieldFactory featureFieldFactory : featureFieldFactories) {
            String fieldName = featureFieldFactory.getFieldName();
            String fieldValue = featureValues.getProperty(fieldName);
            if (fieldValue != null) {
                IndexableField indexableField = featureFieldFactory.createIndexableField(fieldValue, Field.Store.YES);
                doc.add(indexableField);
            }
        }

        indexWriter.addDocument(doc);
        System.out.printf("[%7d]: product:\"%s\", px:%d, py:%d\n", docID, productName, patchX, patchY);
        docID++;
    }
项目:Maskana-Gestor-de-Conocimiento    文件:ReadTokensTask.java   
@Override
public int doLogic() throws Exception {
  List<IndexableField> fields = doc.getFields();
  Analyzer analyzer = getRunData().getAnalyzer();
  int tokenCount = 0;
  for(final IndexableField field : fields) {
    if (!field.fieldType().tokenized() ||
        field instanceof IntField ||
        field instanceof LongField ||
        field instanceof FloatField ||
        field instanceof DoubleField) {
      continue;
    }

    final TokenStream stream = field.tokenStream(analyzer);
    // reset the TokenStream to the first token
    stream.reset();

    TermToBytesRefAttribute termAtt = stream.getAttribute(TermToBytesRefAttribute.class);
    while(stream.incrementToken()) {
      termAtt.fillBytesRef();
      tokenCount++;
    }
    stream.end();
    stream.close();
  }
  totalTokenCount += tokenCount;
  return tokenCount;
}
项目:Maskana-Gestor-de-Conocimiento    文件:TestSearchAfter.java   
@Override
public void setUp() throws Exception {
  super.setUp();
  dir = newDirectory();
  RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
  int numDocs = atLeast(200);
  for (int i = 0; i < numDocs; i++) {
    Document document = new Document();
    document.add(newTextField("english", English.intToEnglish(i), Field.Store.NO));
    document.add(newTextField("oddeven", (i % 2 == 0) ? "even" : "odd", Field.Store.NO));
    document.add(newStringField("byte", "" + ((byte) random().nextInt()), Field.Store.NO));
    document.add(newStringField("short", "" + ((short) random().nextInt()), Field.Store.NO));
    document.add(new IntField("int", random().nextInt(), Field.Store.NO));
    document.add(new LongField("long", random().nextLong(), Field.Store.NO));

    document.add(new FloatField("float", random().nextFloat(), Field.Store.NO));
    document.add(new DoubleField("double", random().nextDouble(), Field.Store.NO));
    document.add(newStringField("bytes", _TestUtil.randomRealisticUnicodeString(random()), Field.Store.NO));
    document.add(newStringField("bytesval", _TestUtil.randomRealisticUnicodeString(random()), Field.Store.NO));
    document.add(new DoubleField("double", random().nextDouble(), Field.Store.NO));

    if (supportsDocValues) {
      document.add(new NumericDocValuesField("intdocvalues", random().nextInt()));
      document.add(new FloatDocValuesField("floatdocvalues", random().nextFloat()));
      document.add(new SortedDocValuesField("sortedbytesdocvalues", new BytesRef(_TestUtil.randomRealisticUnicodeString(random()))));
      document.add(new SortedDocValuesField("sortedbytesdocvaluesval", new BytesRef(_TestUtil.randomRealisticUnicodeString(random()))));
      document.add(new BinaryDocValuesField("straightbytesdocvalues", new BytesRef(_TestUtil.randomRealisticUnicodeString(random()))));
    }
    iw.addDocument(document);
  }
  reader = iw.getReader();
  iw.close();
  searcher = newSearcher(reader);
}
项目:LuceneDB    文件:LuceneValuesDB.java   
/**
 * exact search
 * @param fieldNum field num
 * @param fieldValue field value
 * @param n max results
 * @return document list
 * @throws IOException IOException
 */
public Document[] exactSearch(int fieldNum, String fieldValue, int n) throws IOException {
    IndexSearcher searcher = manager.acquire();
    if (n < 0) {
        n = writer.maxDoc();
    }
    Query query = null;
    TopDocs top = null;
    String fieldName = fieldNames[fieldNum];
    switch(fieldTypeEnums[fieldNum]) {
    case DoubleField:
        double doubleValue = Double.valueOf(fieldValue);
        query = NumericRangeQuery.newDoubleRange(fieldName, doubleValue, doubleValue, true, true);
        break;
    case FloatField:
        float floatValue = Float.valueOf(fieldValue);
        query = NumericRangeQuery.newFloatRange(fieldName, floatValue, floatValue, true, true);
        break;
    case IntField:
        int intValue = Integer.valueOf(fieldValue);
        query = NumericRangeQuery.newIntRange(fieldName, intValue, intValue, true, true);
        break;
    case LongField:
        long longValue = Long.valueOf(fieldValue);
        query = NumericRangeQuery.newLongRange(fieldName, longValue, longValue, true, true);
        break;
    case StoredField:
        break;
    case StringField:
        query = new TermQuery(new Term(fieldName, fieldValue));
        break;
    case TextField:
        // parser is not MTSafe. create new instance
        query = createQueryParser().createPhraseQuery(fieldName, fieldValue);
        ExactCollector collector = new ExactCollector(searcher, fieldName, fieldValue, n);
        searcher.search(query, collector);
        top = collector.topDocs();
        break;
    }
    // not TextField
    if (top == null && query != null) {
        top = searcher.search(query, n, Sort.INDEXORDER);
    }

    Document[] docs = createDocumentResult(searcher, top);
    manager.release(searcher);
    return docs;
}
项目:search    文件:TestNumericRangeQuery32.java   
@Test
public void testInfiniteValues() throws Exception {
  Directory dir = newDirectory();
  RandomIndexWriter writer = new RandomIndexWriter(random(), dir,
    newIndexWriterConfig(new MockAnalyzer(random())));
  Document doc = new Document();
  doc.add(new FloatField("float", Float.NEGATIVE_INFINITY, Field.Store.NO));
  doc.add(new IntField("int", Integer.MIN_VALUE, Field.Store.NO));
  writer.addDocument(doc);

  doc = new Document();
  doc.add(new FloatField("float", Float.POSITIVE_INFINITY, Field.Store.NO));
  doc.add(new IntField("int", Integer.MAX_VALUE, Field.Store.NO));
  writer.addDocument(doc);

  doc = new Document();
  doc.add(new FloatField("float", 0.0f, Field.Store.NO));
  doc.add(new IntField("int", 0, Field.Store.NO));
  writer.addDocument(doc);

  for (float f : TestNumericUtils.FLOAT_NANs) {
    doc = new Document();
    doc.add(new FloatField("float", f, Field.Store.NO));
    writer.addDocument(doc);
  }

  writer.close();

  IndexReader r = DirectoryReader.open(dir);
  IndexSearcher s = newSearcher(r);

  Query q=NumericRangeQuery.newIntRange("int", null, null, true, true);
  TopDocs topDocs = s.search(q, 10);
  assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newIntRange("int", null, null, false, false);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newIntRange("int", Integer.MIN_VALUE, Integer.MAX_VALUE, true, true);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newIntRange("int", Integer.MIN_VALUE, Integer.MAX_VALUE, false, false);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 1,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newFloatRange("float", null, null, true, true);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newFloatRange("float", null, null, false, false);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newFloatRange("float", Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, true, true);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newFloatRange("float", Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, false, false);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 1,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newFloatRange("float", Float.NaN, Float.NaN, true, true);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", TestNumericUtils.FLOAT_NANs.length,  topDocs.scoreDocs.length );

  r.close();
  dir.close();
}
项目:search    文件:TrieField.java   
@Override
public IndexableField createField(SchemaField field, Object value, float boost) {
  boolean indexed = field.indexed();
  boolean stored = field.stored();
  boolean docValues = field.hasDocValues();

  if (!indexed && !stored && !docValues) {
    if (log.isTraceEnabled())
      log.trace("Ignoring unindexed/unstored field: " + field);
    return null;
  }

  FieldType ft = new FieldType();
  ft.setStored(stored);
  ft.setTokenized(true);
  ft.setIndexed(indexed);
  ft.setOmitNorms(field.omitNorms());
  ft.setIndexOptions(getIndexOptions(field, value.toString()));

  switch (type) {
    case INTEGER:
      ft.setNumericType(NumericType.INT);
      break;
    case FLOAT:
      ft.setNumericType(NumericType.FLOAT);
      break;
    case LONG:
      ft.setNumericType(NumericType.LONG);
      break;
    case DOUBLE:
      ft.setNumericType(NumericType.DOUBLE);
      break;
    case DATE:
      ft.setNumericType(NumericType.LONG);
      break;
    default:
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
  }
  ft.setNumericPrecisionStep(precisionStep);

  final org.apache.lucene.document.Field f;

  switch (type) {
    case INTEGER:
      int i = (value instanceof Number)
        ? ((Number)value).intValue()
        : Integer.parseInt(value.toString());
      f = new org.apache.lucene.document.IntField(field.getName(), i, ft);
      break;
    case FLOAT:
      float fl = (value instanceof Number)
        ? ((Number)value).floatValue()
        : Float.parseFloat(value.toString());
      f = new org.apache.lucene.document.FloatField(field.getName(), fl, ft);
      break;
    case LONG:
      long l = (value instanceof Number)
        ? ((Number)value).longValue()
        : Long.parseLong(value.toString());
      f = new org.apache.lucene.document.LongField(field.getName(), l, ft);
      break;
    case DOUBLE:
      double d = (value instanceof Number)
        ? ((Number)value).doubleValue()
        : Double.parseDouble(value.toString());
      f = new org.apache.lucene.document.DoubleField(field.getName(), d, ft);
      break;
    case DATE:
      Date date = (value instanceof Date)
        ? ((Date)value)
        : dateField.parseMath(null, value.toString());
      f = new org.apache.lucene.document.LongField(field.getName(), date.getTime(), ft);
      break;
    default:
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
  }

  f.setBoost(boost);
  return f;
}
项目:r01fb    文件:LuceneDocumentFactoryBase.java   
@SuppressWarnings("unchecked")
private static <FIELD extends Field> FIELD _createStandardField(final IndexDocumentFieldID fieldId,
                                                                final IndexDocumentStandardFieldType type,
                                                                final FieldType fieldType) {
    // guess the store condition from the fieldType
    Field.Store store = fieldType != null ? fieldType.stored() ? Field.Store.YES    
                                                               : Field.Store.NO
                                          : null;
    // Create the field by means of
    //      - store: the field has to be stored or not 
    //      - fieldType: the field type
    FIELD outField = null;
    switch(type) {
    case Double:
        outField = fieldType == null ? (FIELD)(new DoubleField(fieldId.asString(),0D,store))
                                     : (FIELD)(new DoubleField(fieldId.asString(),0D,fieldType));
        break;
    case Int:
        outField = fieldType == null ? (FIELD)(new IntField(fieldId.asString(),0,store))
                                     : (FIELD)(new IntField(fieldId.asString(),0,fieldType));
        break;
    case Long:
        outField = fieldType == null ? (FIELD)(new LongField(fieldId.asString(),0L,store))
                                     : (FIELD)(new LongField(fieldId.asString(),0L,fieldType));
        break;
    case Float:
        outField = fieldType == null ? (FIELD)(new FloatField(fieldId.asString(),0F,store))
                                     : (FIELD)(new FloatField(fieldId.asString(),0F,fieldType));
        break;
    case String:
        outField = fieldType == null ? (FIELD)(new StringField(fieldId.asString(),"",store))
                                     : (FIELD)(new Field(fieldId.asString(),"",fieldType));
        break;
    case Text:
        outField = fieldType == null ? (FIELD)(new TextField(fieldId.asString(),new StringReader("")))
                                     : (FIELD)(new Field(fieldId.asString(),new StringReader(""),fieldType));
        break;
    default:
        throw new IllegalArgumentException(fieldType + "is NOT a supported type");
    }
    return outField;
}
项目:NYBC    文件:TestNumericRangeQuery32.java   
@Test
public void testInfiniteValues() throws Exception {
  Directory dir = newDirectory();
  RandomIndexWriter writer = new RandomIndexWriter(random(), dir,
    newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
  Document doc = new Document();
  doc.add(new FloatField("float", Float.NEGATIVE_INFINITY, Field.Store.NO));
  doc.add(new IntField("int", Integer.MIN_VALUE, Field.Store.NO));
  writer.addDocument(doc);

  doc = new Document();
  doc.add(new FloatField("float", Float.POSITIVE_INFINITY, Field.Store.NO));
  doc.add(new IntField("int", Integer.MAX_VALUE, Field.Store.NO));
  writer.addDocument(doc);

  doc = new Document();
  doc.add(new FloatField("float", 0.0f, Field.Store.NO));
  doc.add(new IntField("int", 0, Field.Store.NO));
  writer.addDocument(doc);

  for (float f : TestNumericUtils.FLOAT_NANs) {
    doc = new Document();
    doc.add(new FloatField("float", f, Field.Store.NO));
    writer.addDocument(doc);
  }

  writer.close();

  IndexReader r = DirectoryReader.open(dir);
  IndexSearcher s = new IndexSearcher(r);

  Query q=NumericRangeQuery.newIntRange("int", null, null, true, true);
  TopDocs topDocs = s.search(q, 10);
  assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newIntRange("int", null, null, false, false);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newIntRange("int", Integer.MIN_VALUE, Integer.MAX_VALUE, true, true);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newIntRange("int", Integer.MIN_VALUE, Integer.MAX_VALUE, false, false);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 1,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newFloatRange("float", null, null, true, true);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newFloatRange("float", null, null, false, false);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newFloatRange("float", Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, true, true);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newFloatRange("float", Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, false, false);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 1,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newFloatRange("float", Float.NaN, Float.NaN, true, true);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", TestNumericUtils.FLOAT_NANs.length,  topDocs.scoreDocs.length );

  r.close();
  dir.close();
}
项目:NYBC    文件:TrieField.java   
@Override
public IndexableField createField(SchemaField field, Object value, float boost) {
  boolean indexed = field.indexed();
  boolean stored = field.stored();
  boolean docValues = field.hasDocValues();

  if (!indexed && !stored && !docValues) {
    if (log.isTraceEnabled())
      log.trace("Ignoring unindexed/unstored field: " + field);
    return null;
  }

  FieldType ft = new FieldType();
  ft.setStored(stored);
  ft.setTokenized(true);
  ft.setIndexed(indexed);
  ft.setOmitNorms(field.omitNorms());
  ft.setIndexOptions(getIndexOptions(field, value.toString()));

  switch (type) {
    case INTEGER:
      ft.setNumericType(NumericType.INT);
      break;
    case FLOAT:
      ft.setNumericType(NumericType.FLOAT);
      break;
    case LONG:
      ft.setNumericType(NumericType.LONG);
      break;
    case DOUBLE:
      ft.setNumericType(NumericType.DOUBLE);
      break;
    case DATE:
      ft.setNumericType(NumericType.LONG);
      break;
    default:
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
  }
  ft.setNumericPrecisionStep(precisionStep);

  final org.apache.lucene.document.Field f;

  switch (type) {
    case INTEGER:
      int i = (value instanceof Number)
        ? ((Number)value).intValue()
        : Integer.parseInt(value.toString());
      f = new org.apache.lucene.document.IntField(field.getName(), i, ft);
      break;
    case FLOAT:
      float fl = (value instanceof Number)
        ? ((Number)value).floatValue()
        : Float.parseFloat(value.toString());
      f = new org.apache.lucene.document.FloatField(field.getName(), fl, ft);
      break;
    case LONG:
      long l = (value instanceof Number)
        ? ((Number)value).longValue()
        : Long.parseLong(value.toString());
      f = new org.apache.lucene.document.LongField(field.getName(), l, ft);
      break;
    case DOUBLE:
      double d = (value instanceof Number)
        ? ((Number)value).doubleValue()
        : Double.parseDouble(value.toString());
      f = new org.apache.lucene.document.DoubleField(field.getName(), d, ft);
      break;
    case DATE:
      Date date = (value instanceof Date)
        ? ((Date)value)
        : dateField.parseMath(null, value.toString());
      f = new org.apache.lucene.document.LongField(field.getName(), date.getTime(), ft);
      break;
    default:
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
  }

  f.setBoost(boost);
  return f;
}
项目:search-core    文件:TrieField.java   
@Override
public IndexableField createField(SchemaField field, Object value, float boost) {
  boolean indexed = field.indexed();
  boolean stored = field.stored();
  boolean docValues = field.hasDocValues();

  if (!indexed && !stored && !docValues) {
    if (log.isTraceEnabled())
      log.trace("Ignoring unindexed/unstored field: " + field);
    return null;
  }

  FieldType ft = new FieldType();
  ft.setStored(stored);
  ft.setTokenized(true);
  ft.setIndexed(indexed);
  ft.setOmitNorms(field.omitNorms());
  ft.setIndexOptions(getIndexOptions(field, value.toString()));

  switch (type) {
    case INTEGER:
      ft.setNumericType(NumericType.INT);
      break;
    case FLOAT:
      ft.setNumericType(NumericType.FLOAT);
      break;
    case LONG:
      ft.setNumericType(NumericType.LONG);
      break;
    case DOUBLE:
      ft.setNumericType(NumericType.DOUBLE);
      break;
    case DATE:
      ft.setNumericType(NumericType.LONG);
      break;
    default:
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
  }
  ft.setNumericPrecisionStep(precisionStep);

  final org.apache.lucene.document.Field f;

  switch (type) {
    case INTEGER:
      int i = (value instanceof Number)
        ? ((Number)value).intValue()
        : Integer.parseInt(value.toString());
      f = new org.apache.lucene.document.IntField(field.getName(), i, ft);
      break;
    case FLOAT:
      float fl = (value instanceof Number)
        ? ((Number)value).floatValue()
        : Float.parseFloat(value.toString());
      f = new org.apache.lucene.document.FloatField(field.getName(), fl, ft);
      break;
    case LONG:
      long l = (value instanceof Number)
        ? ((Number)value).longValue()
        : Long.parseLong(value.toString());
      f = new org.apache.lucene.document.LongField(field.getName(), l, ft);
      break;
    case DOUBLE:
      double d = (value instanceof Number)
        ? ((Number)value).doubleValue()
        : Double.parseDouble(value.toString());
      f = new org.apache.lucene.document.DoubleField(field.getName(), d, ft);
      break;
    case DATE:
      Date date = (value instanceof Date)
        ? ((Date)value)
        : dateField.parseMath(null, value.toString());
      f = new org.apache.lucene.document.LongField(field.getName(), date.getTime(), ft);
      break;
    default:
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
  }

  f.setBoost(boost);
  return f;
}
项目:read-open-source-code    文件:TrieField.java   
@Override
public IndexableField createField(SchemaField field, Object value, float boost) {
  boolean indexed = field.indexed();
  boolean stored = field.stored();
  boolean docValues = field.hasDocValues();

  if (!indexed && !stored && !docValues) {
    if (log.isTraceEnabled())
      log.trace("Ignoring unindexed/unstored field: " + field);
    return null;
  }

  FieldType ft = new FieldType();
  ft.setStored(stored);
  ft.setTokenized(true);
  ft.setIndexed(indexed);
  ft.setOmitNorms(field.omitNorms());
  ft.setIndexOptions(getIndexOptions(field, value.toString()));

  switch (type) {
    case INTEGER:
      ft.setNumericType(NumericType.INT);
      break;
    case FLOAT:
      ft.setNumericType(NumericType.FLOAT);
      break;
    case LONG:
      ft.setNumericType(NumericType.LONG);
      break;
    case DOUBLE:
      ft.setNumericType(NumericType.DOUBLE);
      break;
    case DATE:
      ft.setNumericType(NumericType.LONG);
      break;
    default:
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
  }
  ft.setNumericPrecisionStep(precisionStep);

  final org.apache.lucene.document.Field f;

  switch (type) {
    case INTEGER:
      int i = (value instanceof Number)
        ? ((Number)value).intValue()
        : Integer.parseInt(value.toString());
      f = new org.apache.lucene.document.IntField(field.getName(), i, ft);
      break;
    case FLOAT:
      float fl = (value instanceof Number)
        ? ((Number)value).floatValue()
        : Float.parseFloat(value.toString());
      f = new org.apache.lucene.document.FloatField(field.getName(), fl, ft);
      break;
    case LONG:
      long l = (value instanceof Number)
        ? ((Number)value).longValue()
        : Long.parseLong(value.toString());
      f = new org.apache.lucene.document.LongField(field.getName(), l, ft);
      break;
    case DOUBLE:
      double d = (value instanceof Number)
        ? ((Number)value).doubleValue()
        : Double.parseDouble(value.toString());
      f = new org.apache.lucene.document.DoubleField(field.getName(), d, ft);
      break;
    case DATE:
      Date date = (value instanceof Date)
        ? ((Date)value)
        : dateField.parseMath(null, value.toString());
      f = new org.apache.lucene.document.LongField(field.getName(), date.getTime(), ft);
      break;
    default:
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
  }

  f.setBoost(boost);
  return f;
}
项目:read-open-source-code    文件:TrieField.java   
@Override
public IndexableField createField(SchemaField field, Object value, float boost) {
  boolean indexed = field.indexed();
  boolean stored = field.stored();
  boolean docValues = field.hasDocValues();

  if (!indexed && !stored && !docValues) {
    if (log.isTraceEnabled())
      log.trace("Ignoring unindexed/unstored field: " + field);
    return null;
  }

  FieldType ft = new FieldType();
  ft.setStored(stored);
  ft.setTokenized(true);
  ft.setIndexed(indexed);
  ft.setOmitNorms(field.omitNorms());
  ft.setIndexOptions(getIndexOptions(field, value.toString()));

  switch (type) {
    case INTEGER:
      ft.setNumericType(NumericType.INT);
      break;
    case FLOAT:
      ft.setNumericType(NumericType.FLOAT);
      break;
    case LONG:
      ft.setNumericType(NumericType.LONG);
      break;
    case DOUBLE:
      ft.setNumericType(NumericType.DOUBLE);
      break;
    case DATE:
      ft.setNumericType(NumericType.LONG);
      break;
    default:
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
  }
  ft.setNumericPrecisionStep(precisionStep);

  final org.apache.lucene.document.Field f;

  switch (type) {
    case INTEGER:
      int i = (value instanceof Number)
        ? ((Number)value).intValue()
        : Integer.parseInt(value.toString());
      f = new org.apache.lucene.document.IntField(field.getName(), i, ft);
      break;
    case FLOAT:
      float fl = (value instanceof Number)
        ? ((Number)value).floatValue()
        : Float.parseFloat(value.toString());
      f = new org.apache.lucene.document.FloatField(field.getName(), fl, ft);
      break;
    case LONG:
      long l = (value instanceof Number)
        ? ((Number)value).longValue()
        : Long.parseLong(value.toString());
      f = new org.apache.lucene.document.LongField(field.getName(), l, ft);
      break;
    case DOUBLE:
      double d = (value instanceof Number)
        ? ((Number)value).doubleValue()
        : Double.parseDouble(value.toString());
      f = new org.apache.lucene.document.DoubleField(field.getName(), d, ft);
      break;
    case DATE:
      Date date = (value instanceof Date)
        ? ((Date)value)
        : dateField.parseMath(null, value.toString());
      f = new org.apache.lucene.document.LongField(field.getName(), date.getTime(), ft);
      break;
    default:
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
  }

  f.setBoost(boost);
  return f;
}
项目:Maskana-Gestor-de-Conocimiento    文件:TestNumericRangeQuery32.java   
@Test
public void testInfiniteValues() throws Exception {
  Directory dir = newDirectory();
  RandomIndexWriter writer = new RandomIndexWriter(random(), dir,
    newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())));
  Document doc = new Document();
  doc.add(new FloatField("float", Float.NEGATIVE_INFINITY, Field.Store.NO));
  doc.add(new IntField("int", Integer.MIN_VALUE, Field.Store.NO));
  writer.addDocument(doc);

  doc = new Document();
  doc.add(new FloatField("float", Float.POSITIVE_INFINITY, Field.Store.NO));
  doc.add(new IntField("int", Integer.MAX_VALUE, Field.Store.NO));
  writer.addDocument(doc);

  doc = new Document();
  doc.add(new FloatField("float", 0.0f, Field.Store.NO));
  doc.add(new IntField("int", 0, Field.Store.NO));
  writer.addDocument(doc);

  for (float f : TestNumericUtils.FLOAT_NANs) {
    doc = new Document();
    doc.add(new FloatField("float", f, Field.Store.NO));
    writer.addDocument(doc);
  }

  writer.close();

  IndexReader r = DirectoryReader.open(dir);
  IndexSearcher s = newSearcher(r);

  Query q=NumericRangeQuery.newIntRange("int", null, null, true, true);
  TopDocs topDocs = s.search(q, 10);
  assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newIntRange("int", null, null, false, false);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newIntRange("int", Integer.MIN_VALUE, Integer.MAX_VALUE, true, true);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newIntRange("int", Integer.MIN_VALUE, Integer.MAX_VALUE, false, false);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 1,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newFloatRange("float", null, null, true, true);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newFloatRange("float", null, null, false, false);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newFloatRange("float", Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, true, true);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newFloatRange("float", Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, false, false);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", 1,  topDocs.scoreDocs.length );

  q=NumericRangeQuery.newFloatRange("float", Float.NaN, Float.NaN, true, true);
  topDocs = s.search(q, 10);
  assertEquals("Score doc count", TestNumericUtils.FLOAT_NANs.length,  topDocs.scoreDocs.length );

  r.close();
  dir.close();
}