当前位置: 首页>>代码示例>>Java>>正文


Java LongField类代码示例

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


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

示例1: newDocument

import org.apache.lucene.document.LongField; //导入依赖的package包/类
/**
 * If paragraph is not null, indexes code in the paragraph, otherwise indexes
 * the notebook name.
 *
 * @param id id of the document, different for Note name and paragraph
 * @param noteName name of the note
 * @param p paragraph
 * @return
 */
private Document newDocument(String id, String noteName, Paragraph p) {
  Document doc = new Document();

  Field pathField = new StringField(ID_FIELD, id, Field.Store.YES);
  doc.add(pathField);
  doc.add(new StringField("title", noteName, Field.Store.YES));

  if (null != p) {
    doc.add(new TextField(SEARCH_FIELD, p.getText(), Field.Store.YES));
    Date date = p.getDateStarted() != null ? p.getDateStarted() : p.getDateCreated();
    doc.add(new LongField("modified", date.getTime(), Field.Store.NO));
  } else {
    doc.add(new TextField(SEARCH_FIELD, noteName, Field.Store.YES));
  }
  return doc;
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:26,代码来源:LuceneSearch.java

示例2: newDocument

import org.apache.lucene.document.LongField; //导入依赖的package包/类
/**
 * If paragraph is not null, indexes code in the paragraph, otherwise indexes
 * the notebook name.
 *
 * @param id id of the document, different for Note name and paragraph
 * @param noteName name of the note
 * @param p paragraph
 * @return
 */
private Document newDocument(String id, String noteName, Paragraph p) {
  Document doc = new Document();

  Field pathField = new StringField(ID_FIELD, id, Field.Store.YES);
  doc.add(pathField);
  doc.add(new StringField("title", noteName, Field.Store.YES));

  if (null != p) {
    doc.add(new TextField(SEARCH_FIELD_TEXT, p.getText(), Field.Store.YES));
    if (p.getTitle() != null) {
      doc.add(new TextField(SEARCH_FIELD_TITLE, p.getTitle(), Field.Store.YES));
    }
    Date date = p.getDateStarted() != null ? p.getDateStarted() : p.getDateCreated();
    doc.add(new LongField("modified", date.getTime(), Field.Store.NO));
  } else {
    doc.add(new TextField(SEARCH_FIELD_TEXT, noteName, Field.Store.YES));
  }
  return doc;
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:29,代码来源:LuceneSearch.java

示例3: addLuceneIndexFields

import org.apache.lucene.document.LongField; //导入依赖的package包/类
private void addLuceneIndexFields(String indexField, List<IndexableField> list, JsonNode node, JsonSchema nodeSchema) {
    JsonNode.Type type = nodeSchema.getSchemaType();
    if (type == JsonNode.Type.ARRAY) {
        for (int i = 0; i < node.getSize(); i++) {
            addLuceneIndexFields(indexField, list, node.get(i), nodeSchema.getItemSchema());
        }
    } else if (type == JsonNode.Type.OBJECT) {
        Iterator<String> properties = node.getProperties();
        while (properties.hasNext()) {
            String propName = properties.next();
            // Index property key for object nodes
            list.add(new StringField(indexField, propName, Field.Store.NO));
        }
    } else if (type == JsonNode.Type.STRING) {
        list.add(new StringField(indexField, node.asString(), Field.Store.NO));
    } else if (type == JsonNode.Type.BOOLEAN) {
        list.add(new StringField(indexField, node.asString(), Field.Store.NO));
    } else if (type == JsonNode.Type.INTEGER) {
        list.add(new LongField(indexField, node.asLong(), Field.Store.NO));
    } else if (type == JsonNode.Type.NUMBER) {
        list.add(new DoubleField(indexField, node.asDouble(), Field.Store.NO));
    } else {
        throw new UnsupportedOperationException("Node type " + type + " not supported for index field " + indexField);
    }
}
 
开发者ID:brutusin,项目名称:flea-db,代码行数:26,代码来源:JsonTransformer.java

示例4: resolveField

import org.apache.lucene.document.LongField; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:ksgwr,项目名称:LuceneDB,代码行数:28,代码来源:LuceneObjectValuesDB.java

示例5: DocState

import org.apache.lucene.document.LongField; //导入依赖的package包/类
public DocState(boolean reuseFields, FieldType ft, FieldType bodyFt) {

      this.reuseFields = reuseFields;
      
      if (reuseFields) {
        fields =  new HashMap<>();
        numericFields = new HashMap<>();
        
        // Initialize the map with the default fields.
        fields.put(BODY_FIELD, new Field(BODY_FIELD, "", bodyFt));
        fields.put(TITLE_FIELD, new Field(TITLE_FIELD, "", ft));
        fields.put(DATE_FIELD, new Field(DATE_FIELD, "", ft));
        fields.put(ID_FIELD, new StringField(ID_FIELD, "", Field.Store.YES));
        fields.put(NAME_FIELD, new Field(NAME_FIELD, "", ft));

        numericFields.put(DATE_MSEC_FIELD, new LongField(DATE_MSEC_FIELD, 0L, Field.Store.NO));
        numericFields.put(TIME_SEC_FIELD, new IntField(TIME_SEC_FIELD, 0, Field.Store.NO));
        
        doc = new Document();
      } else {
        numericFields = null;
        fields = null;
        doc = null;
      }
    }
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:DocMaker.java

示例6: index

import org.apache.lucene.document.LongField; //导入依赖的package包/类
/** Build the example index. */
public void index() throws IOException {
  IndexWriter indexWriter = new IndexWriter(indexDir, new IndexWriterConfig(FacetExamples.EXAMPLES_VER, 
      new WhitespaceAnalyzer()));

  // Add documents with a fake timestamp, 1000 sec before
  // "now", 2000 sec before "now", ...:
  for(int i=0;i<100;i++) {
    Document doc = new Document();
    long then = nowSec - i * 1000;
    // Add as doc values field, so we can compute range facets:
    doc.add(new NumericDocValuesField("timestamp", then));
    // Add as numeric field so we can drill-down:
    doc.add(new LongField("timestamp", then, Field.Store.NO));
    indexWriter.addDocument(doc);
  }

  // Open near-real-time searcher
  searcher = new IndexSearcher(DirectoryReader.open(indexWriter, true));
  indexWriter.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:RangeFacetsExample.java

示例7: setUp

import org.apache.lucene.document.LongField; //导入依赖的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

示例8: testLongFieldMinMax

import org.apache.lucene.document.LongField; //导入依赖的package包/类
public void testLongFieldMinMax() throws Exception {
  Directory dir = newDirectory();
  RandomIndexWriter w = new RandomIndexWriter(random(), dir);
  int numDocs = atLeast(100);
  long minValue = Long.MAX_VALUE;
  long maxValue = Long.MIN_VALUE;
  for(int i=0;i<numDocs;i++ ){
    Document doc = new Document();
    long num = random().nextLong();
    minValue = Math.min(num, minValue);
    maxValue = Math.max(num, maxValue);
    doc.add(new LongField("field", num, Field.Store.NO));
    w.addDocument(doc);
  }
  
  IndexReader r = w.getReader();

  Terms terms = MultiFields.getTerms(r, "field");
  assertEquals(minValue, NumericUtils.getMinLong(terms));
  assertEquals(maxValue, NumericUtils.getMaxLong(terms));

  r.close();
  w.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:TestTerms.java

示例9: indexFile

import org.apache.lucene.document.LongField; //导入依赖的package包/类
/**
 * Adds a file to index with {@link IndexWriter}.
 * @param file will be indexed by the function
 */
public void indexFile(final File file) {
    FileInputStream fis = getInputStream(file);
    Document doc = documentFactory.createDocument();
    // Add the path of the file as a field named "path". Use a field that is indexed (i.e. searchable), but don't tokenize
    // the field into separate words and don't index term frequency or positional information:
    Field pathField = new StringField(fieldName, file.getAbsolutePath(), Field.Store.YES);
    doc.add(pathField);

    // Add the last modified date of the file a field named "modified".
    // Use a LongField that is indexed (i.e. efficiently filterable with NumericRangeFilter).
    doc.add(new LongField("modified", file.lastModified(), Field.Store.NO));

    // Add the contents of the file to a field named "contents".
    // If that's not the case searching for special characters will fail.
    BufferedReader bufferedReader;
    try {
        bufferedReader = bufferedReaderFactory.createReader(fis);
        doc.add(new Field("contents", bufferedReader, TextField.TYPE_NOT_STORED));
        addDocument(file, doc);
        fis.close();
    } catch (IOException e) {
        logger.error(" caught a " + e.getClass() + "\n with message: " + e.getMessage());
    }
}
 
开发者ID:epam,项目名称:Wilma,代码行数:29,代码来源:FileIndexer.java

示例10: index

import org.apache.lucene.document.LongField; //导入依赖的package包/类
public void index(Item item) throws IOException {
	String id = item.getId();
   	String text = item.getText();
   	
   	long publicationTIme = item.getPublicationTime();
   	
   	Document document = new Document();
	
	Field idField = new StringField("id", id, Store.YES);
   	document.add(idField);
	
	FieldType fieldType = new FieldType();
	fieldType.setStored(true);
	fieldType.setIndexed(true);
	fieldType.setStoreTermVectors(true);
	document.add(new Field("text", text, fieldType));
	
	document.add(new LongField("publicationTIme", publicationTIme, LongField.TYPE_STORED));
	if(iwriter != null) {
		iwriter.addDocument(document);
	}
}
 
开发者ID:MKLab-ITI,项目名称:mgraph-summarization,代码行数:23,代码来源:LuceneTextIndex.java

示例11: addTweetToIndex

import org.apache.lucene.document.LongField; //导入依赖的package包/类
private static void addTweetToIndex(Tweet headline, IndexWriter writer) throws IOException {
	
	Document doc = new Document();
	Field timestamp = new LongField(FieldNames.TIMESTAMP.name(), headline.getTimestamp().getTime(), Field.Store.YES);
	Field tweetID = new LongField(FieldNames.TWEETID.name(), headline.getTweetID(), Field.Store.NO);
	Field userName = new StringField(FieldNames.USERNAME.name(), headline.getUserName(), Store.YES);
	Field userID = new LongField(FieldNames.USERID.name(), headline.getUserID(), Field.Store.NO);
	Field tweet = new TextField(FieldNames.TEXT.name(), headline.getText(), Field.Store.YES);

	doc.add(tweet);
	doc.add(tweetID);
	doc.add(userName);
	doc.add(userID);
	doc.add(timestamp);
	
	writer.addDocument(doc);
}
 
开发者ID:ommirandap,项目名称:HeadlinesTweetsSearcher,代码行数:18,代码来源:IndexTweets.java

示例12: createDoc_Tour

import org.apache.lucene.document.LongField; //导入依赖的package包/类
private static void createDoc_Tour(	final IndexWriter indexWriter,
									final long tourId,
									final String title,
									final String description,
									final long time) throws IOException {

	final Document doc = new Document();

	doc.add(new IntField(SEARCH_FIELD_DOC_SOURCE, DOC_SOURCE_TOUR, Store.YES));

	doc.add(new LongField(SEARCH_FIELD_TOUR_ID, tourId, Store.YES));
	doc.add(new LongField(SEARCH_FIELD_TIME, time, createFieldType_Long()));

	if (title != null) {
		doc.add(new Field(SEARCH_FIELD_TITLE, title, createFieldType_Text()));
	}

	if (description != null) {
		doc.add(new Field(SEARCH_FIELD_DESCRIPTION, description, createFieldType_Text()));
	}

	indexWriter.addDocument(doc);
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:24,代码来源:FTSearchManager.java

示例13: create

import org.apache.lucene.document.LongField; //导入依赖的package包/类
@Nonnull
public static RecordDoc create(@Nonnull Record record, long indexTime) {
	checkNotNull(record);

	Document doc = new Document();
	doc.add(new StringField(RECORD_URI, record.getUri().toString(), Store.YES));
	doc.add(new StringField(RECORD_PATH, record.getPath(), Store.YES));
	doc.add(new StringField(RECORD_PARENT, record.getFolder(), Store.YES));
	doc.add(new StringField(RECORD_NAME, record.getName(), Store.YES));
	doc.add(new LongField(RECORD_TIME, record.getTime(), Store.YES));
	doc.add(new LongField(RECORD_SIZE, record.getSize(), Store.YES));
	doc.add(new StringField(RECORD_DIR, String.valueOf(record.isDir()), Store.YES));
	doc.add(new LongField(INDEX_TIME, indexTime, Store.YES));

	return new RecordDoc(record, doc, indexTime);
}
 
开发者ID:lithiumtech,项目名称:flow,代码行数:17,代码来源:RecordDoc.java

示例14: createDocument

import org.apache.lucene.document.LongField; //导入依赖的package包/类
/**
 * Creates Lucene document with the fields:
 * <ul>
 *  <li>path: relative path from the constructor</li>
 *  <li>id: the same as path</li>
 *  <li>modified: last modified date of the file</li>
 *  <li>filesize: size of the file</li>
 *  <li>title: name of the file</li>
 * </ul>
 * @return New Lucene document.
 */
@Override
public Document createDocument() {
    Document doc = new Document();

    doc.add(new StringField("path", path, Field.Store.YES));
    
    doc.add(new StringField("id", path, Field.Store.YES));

    doc.add(new StringField("modified",
            DateTools.timeToString(file.lastModified(), DateTools.Resolution.MINUTE),
            Field.Store.YES));

    doc.add(new LongField("filesize", file.length(), Field.Store.YES));
    
    doc.add(new TextField("title", file.getName(), Field.Store.YES));
    return doc;
}
 
开发者ID:martinliska,项目名称:MIaS,代码行数:29,代码来源:FileDocument.java

示例15: DocState

import org.apache.lucene.document.LongField; //导入依赖的package包/类
public DocState(boolean reuseFields, FieldType ft, FieldType bodyFt) {

      this.reuseFields = reuseFields;
      
      if (reuseFields) {
        fields =  new HashMap<String,Field>();
        numericFields = new HashMap<String,Field>();
        
        // Initialize the map with the default fields.
        fields.put(BODY_FIELD, new Field(BODY_FIELD, "", bodyFt));
        fields.put(TITLE_FIELD, new Field(TITLE_FIELD, "", ft));
        fields.put(DATE_FIELD, new Field(DATE_FIELD, "", ft));
        fields.put(ID_FIELD, new StringField(ID_FIELD, "", Field.Store.YES));
        fields.put(NAME_FIELD, new Field(NAME_FIELD, "", ft));

        numericFields.put(DATE_MSEC_FIELD, new LongField(DATE_MSEC_FIELD, 0L, Field.Store.NO));
        numericFields.put(TIME_SEC_FIELD, new IntField(TIME_SEC_FIELD, 0, Field.Store.NO));
        
        doc = new Document();
      } else {
        numericFields = null;
        fields = null;
        doc = null;
      }
    }
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:26,代码来源:DocMaker.java


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