本文整理了Java中org.apache.lucene.document.Field.isStored()
方法的一些代码示例,展示了Field.isStored()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Field.isStored()
方法的具体详情如下:
包路径:org.apache.lucene.document.Field
类名称:Field
方法名:isStored
[英]True iff the value of the field is to be stored in the index for return with search hits. It is an error for this to be true if a field is Reader-valued.
[中]如果字段的值存储在索引中,则返回搜索命中数,则为True。如果字段为读取器值,则此为真是错误的。
代码示例来源:origin: tamingtext/book
/** Append the contents of the specified field to buffer containing text,
* normalizing whitespace in the process.
*
* @param buf
* @param f
*/
protected static void appendFieldText(StringBuilder buf, Field f) {
if (f == null) return;
if (f.isBinary()) return;
if (!f.isStored()) return;
if (buf.length() > 0) buf.append(' ');
String s = f.stringValue();
s = s.replaceAll("\\s+", " "); // normalize whitespace.
buf.append(s);
}
代码示例来源:origin: org.sonatype.nexus/nexus-indexer
public void writeDocument( Document document )
throws IOException
{
@SuppressWarnings( "unchecked" )
List<Field> fields = document.getFields();
int fieldCount = 0;
for ( Field field : fields )
{
if ( field.isStored() )
{
fieldCount++;
}
}
dos.writeInt( fieldCount );
for ( Field field : fields )
{
if ( field.isStored() )
{
writeField( field );
}
}
}
代码示例来源:origin: org.sonatype.nexus/nexus-indexer
public void writeField( Field field )
throws IOException
{
int flags = ( field.isIndexed() ? F_INDEXED : 0 ) //
+ ( field.isTokenized() ? F_TOKENIZED : 0 ) //
+ ( field.isStored() ? F_STORED : 0 ) //
+ ( field.isCompressed() ? F_COMPRESSED : 0 );
String name = field.name();
String value = field.stringValue();
dos.write( flags );
dos.writeUTF( name );
writeUTF( value, dos );
}
代码示例来源:origin: tamingtext/book
if (f.isStored() && !f.isBinary()) {
String fieldValue = f.stringValue().toLowerCase();
for (String cat: categories.keySet()) {
代码示例来源:origin: lucene/lucene
final void addDocument(Document doc) throws IOException {
indexStream.writeLong(fieldsStream.getFilePointer());
int storedCount = 0;
Enumeration fields = doc.fields();
while (fields.hasMoreElements()) {
Field field = (Field)fields.nextElement();
if (field.isStored())
storedCount++;
}
fieldsStream.writeVInt(storedCount);
fields = doc.fields();
while (fields.hasMoreElements()) {
Field field = (Field)fields.nextElement();
if (field.isStored()) {
fieldsStream.writeVInt(fieldInfos.fieldNumber(field.name()));
byte bits = 0;
if (field.isTokenized())
bits |= 1;
fieldsStream.writeByte(bits);
fieldsStream.writeString(field.stringValue());
}
}
}
}
代码示例来源:origin: tamingtext/book
/** dump the values stored in the specified field for each document.
*
* <pre>term(tab)document_frequency</pre>
*
* @param indexDir the index to read.
* @param field the name of the field.
* @param out the print writer output will be written to
* @throws IOException
*/
public static void dumpDocumentFields(File indexDir, String field, long maxDocs, PrintWriter out) throws IOException {
Directory dir = FSDirectory.open(indexDir);
IndexReader reader = IndexReader.open(dir, true);
int max = reader.maxDoc();
for (int i=0; i < max; i++) {
if (!reader.isDeleted(i)) {
Document d = reader.document(i);
for (Field f: d.getFields(field)) {
if (f.isStored() && !f.isBinary()) {
String value = f.stringValue();
if (value != null) {
out.printf("%s\n", value);
}
}
}
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!