• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FloatDocValuesField类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.lucene.document.FloatDocValuesField的典型用法代码示例。如果您正苦于以下问题:Java FloatDocValuesField类的具体用法?Java FloatDocValuesField怎么用?Java FloatDocValuesField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FloatDocValuesField类属于org.apache.lucene.document包,在下文中一共展示了FloatDocValuesField类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setUp

import org.apache.lucene.document.FloatDocValuesField; //导入依赖的package包/类
@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);
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:TestExpressionSorts.java


示例2: createDocValueFieldTemplate

import org.apache.lucene.document.FloatDocValuesField; //导入依赖的package包/类
/**
 * Creates a DocValue field template for a NON-language dependent type
 * @param fieldCfg
 * @return
 */
@SuppressWarnings("unchecked")
public static <FIELD extends Field> FIELD createDocValueFieldTemplate(final IndexDocumentFieldConfig<IndexDocumentValueFieldType> fieldCfg) {
	if (fieldCfg == null) return null;

	IndexDocumentFieldID fieldId = fieldCfg.getId();
	FIELD outField = null;
	switch(fieldCfg.getType()) {
	case Double:
		outField = (FIELD)(new DoubleDocValuesField(fieldId.asString(),0D));
		break;
	case Float:
		outField = (FIELD)(new FloatDocValuesField(fieldId.asString(),0F));
		break;
	default:
		throw new IllegalArgumentException(fieldCfg.getType() + "is NOT a supported type");
	}
	return outField;
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:24,代码来源:LuceneDocumentFactoryBase.java


示例3: setUp

import org.apache.lucene.document.FloatDocValuesField; //导入依赖的package包/类
@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);
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:27,代码来源:TestExpressionSorts.java


示例4: buildDoc

import org.apache.lucene.document.FloatDocValuesField; //导入依赖的package包/类
public static Document buildDoc(String text, float value) throws IOException {
    String id = UUID.randomUUID().toString();
    Document d = new Document();
    d.add(newStringField("id", id, Field.Store.YES));
    d.add(newStringField("text", text, Field.Store.NO));
    d.add(new FloatDocValuesField("score", value));
    return d;
}
 
开发者ID:o19s,项目名称:elasticsearch-learning-to-rank,代码行数:9,代码来源:LoggingFetchSubPhaseTests.java


示例5: testBasicFloat

import org.apache.lucene.document.FloatDocValuesField; //导入依赖的package包/类
public void testBasicFloat() throws Exception {
  Directory d = newDirectory();
  RandomIndexWriter w = new RandomIndexWriter(random(), d);
  Document doc = new Document();
  FloatDocValuesField field = new FloatDocValuesField("field", 0.0f);
  doc.add(field);
  for(long l=0;l<100;l++) {
    field.setFloatValue(l);
    w.addDocument(doc);
  }

  IndexReader r = w.getReader();

  FacetsCollector fc = new FacetsCollector();

  IndexSearcher s = newSearcher(r);
  s.search(new MatchAllDocsQuery(), fc);

  Facets facets = new DoubleRangeFacetCounts("field", new FloatFieldSource("field"), fc,
      new DoubleRange("less than 10", 0.0f, true, 10.0f, false),
      new DoubleRange("less than or equal to 10", 0.0f, true, 10.0f, true),
      new DoubleRange("over 90", 90.0f, false, 100.0f, false),
      new DoubleRange("90 or above", 90.0f, true, 100.0f, false),
      new DoubleRange("over 1000", 1000.0f, false, Double.POSITIVE_INFINITY, false));
  
  assertEquals("dim=field path=[] value=21 childCount=5\n  less than 10 (10)\n  less than or equal to 10 (11)\n  over 90 (9)\n  90 or above (10)\n  over 1000 (0)\n",
               facets.getTopChildren(10, "field").toString());
  
  IOUtils.close(w, r, d);
}
 
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:TestRangeFacetCounts.java


示例6: testFloat

import org.apache.lucene.document.FloatDocValuesField; //导入依赖的package包/类
/** Tests sorting on type float */
public void testFloat() throws IOException {
  Directory dir = newDirectory();
  RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
  Document doc = new Document();
  doc.add(new FloatDocValuesField("value", 30.1F));
  doc.add(newStringField("value", "30.1", Field.Store.YES));
  writer.addDocument(doc);
  doc = new Document();
  doc.add(new FloatDocValuesField("value", -1.3F));
  doc.add(newStringField("value", "-1.3", Field.Store.YES));
  writer.addDocument(doc);
  doc = new Document();
  doc.add(new FloatDocValuesField("value", 4.2F));
  doc.add(newStringField("value", "4.2", Field.Store.YES));
  writer.addDocument(doc);
  IndexReader ir = writer.getReader();
  writer.close();
  
  IndexSearcher searcher = newSearcher(ir);
  Sort sort = new Sort(new SortField("value", SortField.Type.FLOAT));

  TopDocs td = searcher.search(new MatchAllDocsQuery(), 10, sort);
  assertEquals(3, td.totalHits);
  // numeric order
  assertEquals("-1.3", searcher.doc(td.scoreDocs[0].doc).get("value"));
  assertEquals("4.2", searcher.doc(td.scoreDocs[1].doc).get("value"));
  assertEquals("30.1", searcher.doc(td.scoreDocs[2].doc).get("value"));
  assertNoFieldCaches();

  ir.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:34,代码来源:TestSortDocValues.java


示例7: testFloatReverse

import org.apache.lucene.document.FloatDocValuesField; //导入依赖的package包/类
/** Tests sorting on type float in reverse */
public void testFloatReverse() throws IOException {
  Directory dir = newDirectory();
  RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
  Document doc = new Document();
  doc.add(new FloatDocValuesField("value", 30.1F));
  doc.add(newStringField("value", "30.1", Field.Store.YES));
  writer.addDocument(doc);
  doc = new Document();
  doc.add(new FloatDocValuesField("value", -1.3F));
  doc.add(newStringField("value", "-1.3", Field.Store.YES));
  writer.addDocument(doc);
  doc = new Document();
  doc.add(new FloatDocValuesField("value", 4.2F));
  doc.add(newStringField("value", "4.2", Field.Store.YES));
  writer.addDocument(doc);
  IndexReader ir = writer.getReader();
  writer.close();
  
  IndexSearcher searcher = newSearcher(ir);
  Sort sort = new Sort(new SortField("value", SortField.Type.FLOAT, true));

  TopDocs td = searcher.search(new MatchAllDocsQuery(), 10, sort);
  assertEquals(3, td.totalHits);
  // reverse numeric order
  assertEquals("30.1", searcher.doc(td.scoreDocs[0].doc).get("value"));
  assertEquals("4.2", searcher.doc(td.scoreDocs[1].doc).get("value"));
  assertEquals("-1.3", searcher.doc(td.scoreDocs[2].doc).get("value"));
  assertNoFieldCaches();

  ir.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:34,代码来源:TestSortDocValues.java


示例8: testFloatMissing

import org.apache.lucene.document.FloatDocValuesField; //导入依赖的package包/类
/** Tests sorting on type float with a missing value */
public void testFloatMissing() throws IOException {
  Directory dir = newDirectory();
  RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
  Document doc = new Document();
  writer.addDocument(doc);
  doc = new Document();
  doc.add(new FloatDocValuesField("value", -1.3F));
  doc.add(newStringField("value", "-1.3", Field.Store.YES));
  writer.addDocument(doc);
  doc = new Document();
  doc.add(new FloatDocValuesField("value", 4.2F));
  doc.add(newStringField("value", "4.2", Field.Store.YES));
  writer.addDocument(doc);
  IndexReader ir = writer.getReader();
  writer.close();
  
  IndexSearcher searcher = newSearcher(ir);
  Sort sort = new Sort(new SortField("value", SortField.Type.FLOAT));

  TopDocs td = searcher.search(new MatchAllDocsQuery(), 10, sort);
  assertEquals(3, td.totalHits);
  // null is treated as 0
  assertEquals("-1.3", searcher.doc(td.scoreDocs[0].doc).get("value"));
  assertNull(searcher.doc(td.scoreDocs[1].doc).get("value"));
  assertEquals("4.2", searcher.doc(td.scoreDocs[2].doc).get("value"));

  ir.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:TestSortDocValues.java


示例9: testFloatMissingLast

import org.apache.lucene.document.FloatDocValuesField; //导入依赖的package包/类
/** Tests sorting on type float, specifying the missing value should be treated as Float.MAX_VALUE */
public void testFloatMissingLast() throws IOException {
  Directory dir = newDirectory();
  RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
  Document doc = new Document();
  writer.addDocument(doc);
  doc = new Document();
  doc.add(new FloatDocValuesField("value", -1.3F));
  doc.add(newStringField("value", "-1.3", Field.Store.YES));
  writer.addDocument(doc);
  doc = new Document();
  doc.add(new FloatDocValuesField("value", 4.2F));
  doc.add(newStringField("value", "4.2", Field.Store.YES));
  writer.addDocument(doc);
  IndexReader ir = writer.getReader();
  writer.close();
  
  IndexSearcher searcher = newSearcher(ir);
  SortField sortField = new SortField("value", SortField.Type.FLOAT);
  sortField.setMissingValue(Float.MAX_VALUE);
  Sort sort = new Sort(sortField);

  TopDocs td = searcher.search(new MatchAllDocsQuery(), 10, sort);
  assertEquals(3, td.totalHits);
  // null is treated as Float.MAX_VALUE
  assertEquals("-1.3", searcher.doc(td.scoreDocs[0].doc).get("value"));
  assertEquals("4.2", searcher.doc(td.scoreDocs[1].doc).get("value"));
  assertNull(searcher.doc(td.scoreDocs[2].doc).get("value"));

  ir.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:33,代码来源:TestSortDocValues.java


示例10: testFloat

import org.apache.lucene.document.FloatDocValuesField; //导入依赖的package包/类
/** Tests sorting on type float */
public void testFloat() throws IOException {
  Directory dir = newDirectory();
  RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
  Document doc = new Document();
  doc.add(new FloatDocValuesField("value", 30.1F));
  doc.add(newStringField("value", "30.1", Field.Store.YES));
  writer.addDocument(doc);
  doc = new Document();
  doc.add(new FloatDocValuesField("value", -1.3F));
  doc.add(newStringField("value", "-1.3", Field.Store.YES));
  writer.addDocument(doc);
  doc = new Document();
  doc.add(new FloatDocValuesField("value", 4.2F));
  doc.add(newStringField("value", "4.2", Field.Store.YES));
  writer.addDocument(doc);
  IndexReader ir = writer.getReader();
  writer.close();
  
  IndexSearcher searcher = new IndexSearcher(ir);
  Sort sort = new Sort(new SortField("value", SortField.Type.FLOAT));

  TopDocs td = searcher.search(new MatchAllDocsQuery(), 10, sort);
  assertEquals(3, td.totalHits);
  // numeric order
  assertEquals("-1.3", searcher.doc(td.scoreDocs[0].doc).get("value"));
  assertEquals("4.2", searcher.doc(td.scoreDocs[1].doc).get("value"));
  assertEquals("30.1", searcher.doc(td.scoreDocs[2].doc).get("value"));
  assertNoFieldCaches();

  ir.close();
  dir.close();
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:34,代码来源:TestSortDocValues.java


示例11: testFloatReverse

import org.apache.lucene.document.FloatDocValuesField; //导入依赖的package包/类
/** Tests sorting on type float in reverse */
public void testFloatReverse() throws IOException {
  Directory dir = newDirectory();
  RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
  Document doc = new Document();
  doc.add(new FloatDocValuesField("value", 30.1F));
  doc.add(newStringField("value", "30.1", Field.Store.YES));
  writer.addDocument(doc);
  doc = new Document();
  doc.add(new FloatDocValuesField("value", -1.3F));
  doc.add(newStringField("value", "-1.3", Field.Store.YES));
  writer.addDocument(doc);
  doc = new Document();
  doc.add(new FloatDocValuesField("value", 4.2F));
  doc.add(newStringField("value", "4.2", Field.Store.YES));
  writer.addDocument(doc);
  IndexReader ir = writer.getReader();
  writer.close();
  
  IndexSearcher searcher = new IndexSearcher(ir);
  Sort sort = new Sort(new SortField("value", SortField.Type.FLOAT, true));

  TopDocs td = searcher.search(new MatchAllDocsQuery(), 10, sort);
  assertEquals(3, td.totalHits);
  // reverse numeric order
  assertEquals("30.1", searcher.doc(td.scoreDocs[0].doc).get("value"));
  assertEquals("4.2", searcher.doc(td.scoreDocs[1].doc).get("value"));
  assertEquals("-1.3", searcher.doc(td.scoreDocs[2].doc).get("value"));
  assertNoFieldCaches();

  ir.close();
  dir.close();
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:34,代码来源:TestSortDocValues.java


示例12: setUp

import org.apache.lucene.document.FloatDocValuesField; //导入依赖的package包/类
@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);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:35,代码来源:TestSearchAfter.java


示例13: main

import org.apache.lucene.document.FloatDocValuesField; //导入依赖的package包/类
/**
 * Since Lucene 6.6.0 the index time boosting has been deprecated. How we suppose to solve it now?
 */
public static void main(String[] args) throws IOException {

  Directory dir = new RAMDirectory();
  Analyzer analyzer = new StandardAnalyzer();
  IndexWriterConfig iwc = new IndexWriterConfig(analyzer);
  iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE);
  IndexWriter writer = new IndexWriter(dir, iwc);

  Document doc1 = new Document();
  doc1.add(new TextField("title", "The biggest title in the world", Store.YES));
  doc1.add(new TextField("description", "short descr", Store.YES));
  doc1.add(new FloatDocValuesField("doc_boost", 1.30f));
  writer.addDocument(doc1);

  Document doc2 = new Document();
  doc2.add(new TextField("title", "Not so important title", Store.YES));
  doc1.add(new TextField("description", "very valuable descr", Store.YES));
  doc1.add(new FloatDocValuesField("doc_boost", 3.30f));
  writer.addDocument(doc2);

  writer.close();

  IndexReader reader = DirectoryReader.open(dir);
  IndexSearcher searcher = new IndexSearcher(reader);

  Query query = new MatchAllDocsQuery();
  Query q = new FunctionScoreQuery(query, DoubleValuesSource.fromFloatField("doc_boost"));

  final ScoreDoc[] scoreDocs = searcher.search(q, 10).scoreDocs;
  for (ScoreDoc doc : scoreDocs) {
    System.out.println(doc.doc + " " + doc.score);
  }
}
 
开发者ID:MysterionRise,项目名称:information-retrieval-adventure,代码行数:37,代码来源:IndexTimeScoringFactors.java


示例14: testBasicFloat

import org.apache.lucene.document.FloatDocValuesField; //导入依赖的package包/类
public void testBasicFloat() throws Exception {
  Directory d = newDirectory();
  RandomIndexWriter w = new RandomIndexWriter(random(), d);
  Document doc = new Document();
  FloatDocValuesField field = new FloatDocValuesField("field", 0.0f);
  doc.add(field);
  for(long l=0;l<100;l++) {
    field.setFloatValue(l);
    w.addDocument(doc);
  }

  IndexReader r = w.getReader();
  w.close();

  RangeAccumulator a = new RangeAccumulator(new RangeFacetRequest<FloatRange>("field",
      new FloatRange("less than 10", 0.0f, true, 10.0f, false),
      new FloatRange("less than or equal to 10", 0.0f, true, 10.0f, true),
      new FloatRange("over 90", 90.0f, false, 100.0f, false),
      new FloatRange("90 or above", 90.0f, true, 100.0f, false),
      new FloatRange("over 1000", 1000.0f, false, Float.POSITIVE_INFINITY, false)));
  
  FacetsCollector fc = FacetsCollector.create(a);

  IndexSearcher s = newSearcher(r);
  s.search(new MatchAllDocsQuery(), fc);
  List<FacetResult> result = fc.getFacetResults();
  assertEquals(1, result.size());
  assertEquals("field (0)\n  less than 10 (10)\n  less than or equal to 10 (11)\n  over 90 (9)\n  90 or above (10)\n  over 1000 (0)\n", FacetTestUtils.toSimpleString(result.get(0)));
  
  r.close();
  d.close();
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:33,代码来源:TestRangeAccumulator.java


示例15: addDoc

import org.apache.lucene.document.FloatDocValuesField; //导入依赖的package包/类
private void addDoc(IndexWriter writer, int id) throws IOException
{
  Document doc = new Document();
  doc.add(new TextField("content", "aaa", Field.Store.NO));
  doc.add(new StringField("id", Integer.toString(id), Field.Store.YES));
  FieldType customType2 = new FieldType(TextField.TYPE_STORED);
  customType2.setStoreTermVectors(true);
  customType2.setStoreTermVectorPositions(true);
  customType2.setStoreTermVectorOffsets(true);
  doc.add(new Field("autf8", "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", customType2));
  doc.add(new Field("utf8", "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", customType2));
  doc.add(new Field("content2", "here is more content with aaa aaa aaa", customType2));
  doc.add(new Field("fie\u2C77ld", "field with non-ascii name", customType2));
  // add numeric fields, to test if flex preserves encoding
  doc.add(new IntField("trieInt", id, Field.Store.NO));
  doc.add(new LongField("trieLong", (long) id, Field.Store.NO));
  // add docvalues fields
  doc.add(new NumericDocValuesField("dvByte", (byte) id));
  byte bytes[] = new byte[] {
    (byte)(id >>> 24), (byte)(id >>> 16),(byte)(id >>> 8),(byte)id
  };
  BytesRef ref = new BytesRef(bytes);
  doc.add(new BinaryDocValuesField("dvBytesDerefFixed", ref));
  doc.add(new BinaryDocValuesField("dvBytesDerefVar", ref));
  doc.add(new SortedDocValuesField("dvBytesSortedFixed", ref));
  doc.add(new SortedDocValuesField("dvBytesSortedVar", ref));
  doc.add(new BinaryDocValuesField("dvBytesStraightFixed", ref));
  doc.add(new BinaryDocValuesField("dvBytesStraightVar", ref));
  doc.add(new DoubleDocValuesField("dvDouble", (double)id));
  doc.add(new FloatDocValuesField("dvFloat", (float)id));
  doc.add(new NumericDocValuesField("dvInt", id));
  doc.add(new NumericDocValuesField("dvLong", id));
  doc.add(new NumericDocValuesField("dvPacked", id));
  doc.add(new NumericDocValuesField("dvShort", (short)id));
  // a field with both offsets and term vectors for a cross-check
  FieldType customType3 = new FieldType(TextField.TYPE_STORED);
  customType3.setStoreTermVectors(true);
  customType3.setStoreTermVectorPositions(true);
  customType3.setStoreTermVectorOffsets(true);
  customType3.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
  doc.add(new Field("content5", "here is more content with aaa aaa aaa", customType3));
  // a field that omits only positions
  FieldType customType4 = new FieldType(TextField.TYPE_STORED);
  customType4.setStoreTermVectors(true);
  customType4.setStoreTermVectorPositions(false);
  customType4.setStoreTermVectorOffsets(true);
  customType4.setIndexOptions(IndexOptions.DOCS_AND_FREQS);
  doc.add(new Field("content6", "here is more content with aaa aaa aaa", customType4));
  // TODO: 
  //   index different norms types via similarity (we use a random one currently?!)
  //   remove any analyzer randomness, explicitly add payloads for certain fields.
  writer.addDocument(doc);
}
 
开发者ID:europeana,项目名称:search,代码行数:54,代码来源:TestBackwardsCompatibility3x.java


示例16: addDoc

import org.apache.lucene.document.FloatDocValuesField; //导入依赖的package包/类
private void addDoc(IndexWriter writer, int id) throws IOException
{
  Document doc = new Document();
  doc.add(new TextField("content", "aaa", Field.Store.NO));
  doc.add(new StringField("id", Integer.toString(id), Field.Store.YES));
  FieldType customType2 = new FieldType(TextField.TYPE_STORED);
  customType2.setStoreTermVectors(true);
  customType2.setStoreTermVectorPositions(true);
  customType2.setStoreTermVectorOffsets(true);
  doc.add(new Field("autf8", "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", customType2));
  doc.add(new Field("utf8", "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", customType2));
  doc.add(new Field("content2", "here is more content with aaa aaa aaa", customType2));
  doc.add(new Field("fie\u2C77ld", "field with non-ascii name", customType2));
  // add numeric fields, to test if flex preserves encoding
  doc.add(new IntField("trieInt", id, Field.Store.NO));
  doc.add(new LongField("trieLong", (long) id, Field.Store.NO));
  // add docvalues fields
  doc.add(new NumericDocValuesField("dvByte", (byte) id));
  byte bytes[] = new byte[] {
    (byte)(id >>> 24), (byte)(id >>> 16),(byte)(id >>> 8),(byte)id
  };
  BytesRef ref = new BytesRef(bytes);
  doc.add(new BinaryDocValuesField("dvBytesDerefFixed", ref));
  doc.add(new BinaryDocValuesField("dvBytesDerefVar", ref));
  doc.add(new SortedDocValuesField("dvBytesSortedFixed", ref));
  doc.add(new SortedDocValuesField("dvBytesSortedVar", ref));
  doc.add(new BinaryDocValuesField("dvBytesStraightFixed", ref));
  doc.add(new BinaryDocValuesField("dvBytesStraightVar", ref));
  doc.add(new DoubleDocValuesField("dvDouble", (double)id));
  doc.add(new FloatDocValuesField("dvFloat", (float)id));
  doc.add(new NumericDocValuesField("dvInt", id));
  doc.add(new NumericDocValuesField("dvLong", id));
  doc.add(new NumericDocValuesField("dvPacked", id));
  doc.add(new NumericDocValuesField("dvShort", (short)id));
  doc.add(new SortedSetDocValuesField("dvSortedSet", ref));
  doc.add(new SortedNumericDocValuesField("dvSortedNumeric", id));
  // a field with both offsets and term vectors for a cross-check
  FieldType customType3 = new FieldType(TextField.TYPE_STORED);
  customType3.setStoreTermVectors(true);
  customType3.setStoreTermVectorPositions(true);
  customType3.setStoreTermVectorOffsets(true);
  customType3.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
  doc.add(new Field("content5", "here is more content with aaa aaa aaa", customType3));
  // a field that omits only positions
  FieldType customType4 = new FieldType(TextField.TYPE_STORED);
  customType4.setStoreTermVectors(true);
  customType4.setStoreTermVectorPositions(false);
  customType4.setStoreTermVectorOffsets(true);
  customType4.setIndexOptions(IndexOptions.DOCS_AND_FREQS);
  doc.add(new Field("content6", "here is more content with aaa aaa aaa", customType4));
  // TODO: 
  //   index different norms types via similarity (we use a random one currently?!)
  //   remove any analyzer randomness, explicitly add payloads for certain fields.
  writer.addDocument(doc);
}
 
开发者ID:europeana,项目名称:search,代码行数:56,代码来源:TestBackwardsCompatibility.java


示例17: addDoc

import org.apache.lucene.document.FloatDocValuesField; //导入依赖的package包/类
private void addDoc(IndexWriter writer, int id) throws IOException
{
  Document doc = new Document();
  doc.add(new TextField("content", "aaa", Field.Store.NO));
  doc.add(new StringField("id", Integer.toString(id), Field.Store.YES));
  FieldType customType2 = new FieldType(TextField.TYPE_STORED);
  customType2.setStoreTermVectors(true);
  customType2.setStoreTermVectorPositions(true);
  customType2.setStoreTermVectorOffsets(true);
  doc.add(new Field("autf8", "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", customType2));
  doc.add(new Field("utf8", "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", customType2));
  doc.add(new Field("content2", "here is more content with aaa aaa aaa", customType2));
  doc.add(new Field("fie\u2C77ld", "field with non-ascii name", customType2));
  // add numeric fields, to test if flex preserves encoding
  doc.add(new IntField("trieInt", id, Field.Store.NO));
  doc.add(new LongField("trieLong", (long) id, Field.Store.NO));
  // add docvalues fields
  doc.add(new NumericDocValuesField("dvByte", (byte) id));
  byte bytes[] = new byte[] {
    (byte)(id >>> 24), (byte)(id >>> 16),(byte)(id >>> 8),(byte)id
  };
  BytesRef ref = new BytesRef(bytes);
  doc.add(new BinaryDocValuesField("dvBytesDerefFixed", ref));
  doc.add(new BinaryDocValuesField("dvBytesDerefVar", ref));
  doc.add(new SortedDocValuesField("dvBytesSortedFixed", ref));
  doc.add(new SortedDocValuesField("dvBytesSortedVar", ref));
  doc.add(new BinaryDocValuesField("dvBytesStraightFixed", ref));
  doc.add(new BinaryDocValuesField("dvBytesStraightVar", ref));
  doc.add(new DoubleDocValuesField("dvDouble", (double)id));
  doc.add(new FloatDocValuesField("dvFloat", (float)id));
  doc.add(new NumericDocValuesField("dvInt", id));
  doc.add(new NumericDocValuesField("dvLong", id));
  doc.add(new NumericDocValuesField("dvPacked", id));
  doc.add(new NumericDocValuesField("dvShort", (short)id));
  doc.add(new SortedSetDocValuesField("dvSortedSet", ref));
  // a field with both offsets and term vectors for a cross-check
  FieldType customType3 = new FieldType(TextField.TYPE_STORED);
  customType3.setStoreTermVectors(true);
  customType3.setStoreTermVectorPositions(true);
  customType3.setStoreTermVectorOffsets(true);
  customType3.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
  doc.add(new Field("content5", "here is more content with aaa aaa aaa", customType3));
  // a field that omits only positions
  FieldType customType4 = new FieldType(TextField.TYPE_STORED);
  customType4.setStoreTermVectors(true);
  customType4.setStoreTermVectorPositions(false);
  customType4.setStoreTermVectorOffsets(true);
  customType4.setIndexOptions(IndexOptions.DOCS_AND_FREQS);
  doc.add(new Field("content6", "here is more content with aaa aaa aaa", customType4));
  // TODO: 
  //   index different norms types via similarity (we use a random one currently?!)
  //   remove any analyzer randomness, explicitly add payloads for certain fields.
  writer.addDocument(doc);
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:55,代码来源:TestBackwardsCompatibility.java



注:本文中的org.apache.lucene.document.FloatDocValuesField类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Type类代码示例发布时间:2022-05-22
下一篇:
Java SampleElements类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap