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


Java Store.YES属性代码示例

本文整理汇总了Java中org.apache.lucene.document.Field.Store.YES属性的典型用法代码示例。如果您正苦于以下问题:Java Store.YES属性的具体用法?Java Store.YES怎么用?Java Store.YES使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.lucene.document.Field.Store的用法示例。


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

示例1: newsToDocument

public static Document newsToDocument(NewsDetailModel news){
	Document document = new Document();
	
	StringField idField = new StringField("id",news.getId(),Store.YES);
	StringField urlField = new StringField("url",news.getUrl(),Store.YES);
	StringField titleField = new StringField("title",news.getTitle(),Store.YES);
	StringField contentField = new StringField("content",news.getContent(),Store.YES);
	StringField timeField = new StringField("time",news.getTime(),Store.YES);
	
	document.add(idField);
	document.add(urlField);
	document.add(titleField);
	document.add(contentField);
	document.add(timeField);

	return document;
}
 
开发者ID:FrankXiong,项目名称:cqunews-web,代码行数:17,代码来源:NewsToDocument.java

示例2: index

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,代码行数:22,代码来源:LuceneTextIndex.java

示例3: addTweetToIndex

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,代码行数:17,代码来源:IndexTweets.java

示例4: add

/**
 * Adds the given {@link IIndexElement} to the index.
 * It builds the {@link Document} with its {@link Field}s and writes it to {@link Index}.
 * @param element the {@link IIndexElement} to add.
 * @throws IOException if an error occurred in the index.
 */
@SuppressWarnings("unchecked")
private void add(final IIndexElement element) throws IOException {
	final IIndexTypeConf conf = indexData.getConf();

	final Document doc = new Document();

	// add id field
	final StringField idField = new StringField(IIndexElement.FIELD_ID, element.getId(), Store.YES);
	doc.add(idField);

	// add index type field
	final StringField indexTypeField = new StringField(IIndexElement.FIELD_INDEX_TYPE, conf.getName(), Store.YES);
	doc.add(indexTypeField);

	final Locale locale = element.getLocale();
	if(element.getLocale() != null) {
		doc.add(new StringField(IIndexElement.FIELD_LOCALE, locale.getLanguage(), Store.YES));
	}

	for (@SuppressWarnings("rawtypes") final IIndexFieldConf fieldConf : conf.getFields()) {
		Object fieldContent = element.getContent(fieldConf.getName());

		if(fieldContent != null) {
			if(!(fieldContent instanceof Collection<?>)) {
				fieldContent = Arrays.asList(fieldContent);
			}

			for (final Object content : (Collection<?>) fieldContent) {
				doc.add(fieldConf.buildField(content));
			}
		}
	}

	index.addDocument(doc, locale);
}
 
开发者ID:XMBomb,项目名称:InComb,代码行数:41,代码来源:IndexingThread.java

示例5: getDocument

private Document getDocument(File file) throws IOException {
	Document document = new Document();
	Field contentsField = new TextField(LuceneConstants.CONTENTS, new String(Files.readAllBytes(file.toPath())), Store.YES);
	Field fileNameField = new Field(LuceneConstants.FILE_NAME, file.getName(), TextField.TYPE_STORED);
	Field filePathField = new Field(LuceneConstants.FILE_PATH, file.getCanonicalPath(), TextField.TYPE_STORED);
	document.add(contentsField);
	document.add(fileNameField);
	document.add(filePathField);
	return document;
}
 
开发者ID:tedyli,项目名称:Tedyli-Searcher,代码行数:10,代码来源:Indexer.java

示例6: add

/**
 * Adds an string field, which may be analyzer or not
 */
public DocumentBuilder add(final String name, final String value, final boolean analyzed) {
    if (StringUtils.isNotEmpty(value)) {
        final Field field = new Field(name, value, Store.YES, analyzed ? Index.ANALYZED : Index.NOT_ANALYZED);
        document.add(field);
    }
    return this;
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:10,代码来源:DocumentBuilder.java

示例7: getKeyBytes

protected void getKeyBytes(Row row) {
    
    byte[] bytes = row.hKey().hKeyBytes();
    keyEncodedString = encodeBytes(bytes, 0, bytes.length);
    Field field = new StringField(IndexedField.KEY_FIELD, keyEncodedString, Store.YES);
    currentDocument.add(field);
}
 
开发者ID:jaytaylor,项目名称:sql-layer,代码行数:7,代码来源:RowIndexer.java

示例8: save

/**
 * save index as text file
 * @param bw buffered writer
 * @param dumper write strategy
 * @throws IOException IOException
 */
public void save(BufferedWriter bw, WriteDocumentStrategy dumper) throws IOException {
	IndexSearcher searcher = manager.acquire();
	IndexReader reader = searcher.getIndexReader();
	int maxDoc = reader.maxDoc();

	int docId = 0;
	List<String> storedFields = new ArrayList<String>(fieldNames.length);
	for(int i=0;i<fieldNames.length;i++) {
		if (stores[i] == Store.YES) {
			storedFields.add(fieldNames[i]);
		}
	}
	if (hasHeader) {
		bw.write(dumper.writeDocument(storedFields.toArray(new String[0])));
		bw.newLine();
	}
	String[] fields = new String[storedFields.size()];
	while(docId<maxDoc) {
		Document doc = reader.document(docId);
		for(int i=0,size=storedFields.size();i<size;i++) {
			fields[i] = doc.get(storedFields.get(i));
		}
		bw.write(dumper.writeDocument(fields));
		bw.newLine();
	}
	bw.close();
}
 
开发者ID:ksgwr,项目名称:LuceneDB,代码行数:33,代码来源:LuceneValuesDB.java

示例9: createStores

@Override
public Store[] createStores(int fieldsLength) {
	Store[] stores = new Store[fieldsLength];
	for(int i=0;i<fieldsLength;i++) {
		stores[i] = Store.YES;
	}
	return stores;
}
 
开发者ID:ksgwr,项目名称:LuceneDB,代码行数:8,代码来源:StandardDocumentCreator.java

示例10: addFields

/** {@inheritDoc} */
@Override
@SuppressWarnings("unchecked")
public void addFields(Document document, DecoratedKey partitionKey) {
    ByteBuffer bb = factory.toByteArray(partitionKey.getToken());
    String serialized = ByteBufferUtils.toString(bb);
    Field field = new StringField(FIELD_NAME, serialized, Store.YES);
    document.add(field);
}
 
开发者ID:Stratio,项目名称:stratio-cassandra,代码行数:9,代码来源:TokenMapperGeneric.java

示例11: main

public static void main(String args[]) throws ParseException, IOException{
	MemoryIndex index = new MemoryIndex();
	Analyzer analyzer = new StandardAnalyzer();
	StringField field3 = new StringField(AUTHOR, FULL_NAME, Store.YES);
	index.addField(field3, analyzer);
	
	Query query = new TermQuery(new Term(AUTHOR,FULL_NAME));
	search(index,query);
	
	query = new TermQuery(new Term(AUTHOR,FIRST_NAME));
	search(index,query);
	
	query = new TermQuery(new Term(AUTHOR,LAST_NAME));
	search(index,query);	
}
 
开发者ID:atulsm,项目名称:Test_Projects,代码行数:15,代码来源:TestLuceneIndexThenSearch.java

示例12: isStored

/**
 * Returns true if the field is storeable.
 */
protected Store isStored() {
	return store ? Store.YES : Store.NO;
}
 
开发者ID:XMBomb,项目名称:InComb,代码行数:6,代码来源:AStoreableIndexFieldConf.java

示例13: testLongFieldCache

public void testLongFieldCache() throws IOException {
  Directory dir = newDirectory();
  IndexWriterConfig cfg = newIndexWriterConfig(new MockAnalyzer(random()));
  cfg.setMergePolicy(newLogMergePolicy());
  RandomIndexWriter iw = new RandomIndexWriter(random(), dir, cfg);
  Document doc = new Document();
  LongField field = new LongField("f", 0L, Store.YES);
  doc.add(field);
  final long[] values = new long[TestUtil.nextInt(random(), 1, 10)];
  for (int i = 0; i < values.length; ++i) {
    final long v;
    switch (random().nextInt(10)) {
      case 0:
        v = Long.MIN_VALUE;
        break;
      case 1:
        v = 0;
        break;
      case 2:
        v = Long.MAX_VALUE;
        break;
      default:
        v = TestUtil.nextLong(random(), -10, 10);
        break;
    }
    values[i] = v;
    if (v == 0 && random().nextBoolean()) {
      // missing
      iw.addDocument(new Document());
    } else {
      field.setLongValue(v);
      iw.addDocument(doc);
    }
  }
  iw.forceMerge(1);
  final DirectoryReader reader = iw.getReader();
  final FieldCache.Longs longs = FieldCache.DEFAULT.getLongs(getOnlySegmentReader(reader), "f", false);
  for (int i = 0; i < values.length; ++i) {
    assertEquals(values[i], longs.get(i));
  }
  reader.close();
  iw.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:44,代码来源:TestFieldCache.java

示例14: testIntFieldCache

public void testIntFieldCache() throws IOException {
  Directory dir = newDirectory();
  IndexWriterConfig cfg = newIndexWriterConfig(new MockAnalyzer(random()));
  cfg.setMergePolicy(newLogMergePolicy());
  RandomIndexWriter iw = new RandomIndexWriter(random(), dir, cfg);
  Document doc = new Document();
  IntField field = new IntField("f", 0, Store.YES);
  doc.add(field);
  final int[] values = new int[TestUtil.nextInt(random(), 1, 10)];
  for (int i = 0; i < values.length; ++i) {
    final int v;
    switch (random().nextInt(10)) {
      case 0:
        v = Integer.MIN_VALUE;
        break;
      case 1:
        v = 0;
        break;
      case 2:
        v = Integer.MAX_VALUE;
        break;
      default:
        v = TestUtil.nextInt(random(), -10, 10);
        break;
    }
    values[i] = v;
    if (v == 0 && random().nextBoolean()) {
      // missing
      iw.addDocument(new Document());
    } else {
      field.setIntValue(v);
      iw.addDocument(doc);
    }
  }
  iw.forceMerge(1);
  final DirectoryReader reader = iw.getReader();
  final FieldCache.Ints ints = FieldCache.DEFAULT.getInts(getOnlySegmentReader(reader), "f", false);
  for (int i = 0; i < values.length; ++i) {
    assertEquals(values[i], ints.get(i));
  }
  reader.close();
  iw.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:44,代码来源:TestFieldCache.java

示例15: getFieldStore

/**
 * @param field
 * @return
 */
public Store getFieldStore(SchemaField field)
{
    if (storeAll)
    {
        return Store.YES;
    }

    PropertyDefinition propertyDefinition = getPropertyDefinition(field.getName());
    if (propertyDefinition != null)
    {
        return propertyDefinition.isStoredInIndex() ? Store.YES : Store.NO;
    }

    NonDictionaryField nonDDField = nonDictionaryFields.get(field.getName());
    if (nonDDField != null)
    {
        return nonDDField.store;
    }

    for (String additionalContentFieldEnding : additionalContentFields.keySet())
    {
        if (field.getName().endsWith(additionalContentFieldEnding)
                && (getPropertyDefinition(field.getName().substring(0, (field.getName().length() - additionalContentFieldEnding.length()))) != null))
        {
            return additionalContentFields.get(additionalContentFieldEnding).store;
        }
    }

    for (String additionalTextFieldEnding : additionalTextFields.keySet())
    {
        if (field.getName().endsWith(additionalTextFieldEnding)
                && (getPropertyDefinition(field.getName().substring(0, (field.getName().length() - additionalTextFieldEnding.length()))) != null))
        {
            return additionalTextFields.get(additionalTextFieldEnding).store;
        }
    }

    for (String additionalMlTextFieldEnding : additionalMlTextFields.keySet())
    {
        if (field.getName().endsWith(additionalMlTextFieldEnding)
                && (getPropertyDefinition(field.getName().substring(0, (field.getName().length() - additionalMlTextFieldEnding.length()))) != null))
        {
            return additionalMlTextFields.get(additionalMlTextFieldEnding).store;
        }
    }

    return Store.NO;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:52,代码来源:AlfrescoSolrDataModel.java


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