[lucene] fields

2020-03-05  本文已影响0人  cdz620

Lucene fields 可接受的option

主要有三类:

Field option 组合使用

header 1 header 2 TermVector Example usage
NOT_ANALYZED_NO_NORMS YES NO Identifiers (filenames, primary keys), telephone and Social Security numbers, URLs, personal names, dates, and textual fields for sorting
ANALYZED YES WITH_POSITIONS_OFFSETS Document title, document abstract
ANALYZED NO WITH_POSITIONS_OFFSETS Document body
NO YES NO Document type, database primary key (if not used for searching)
NOT_ANALYZED NO NO Hidden keywords

Fields option for indexing

Index.ANALYZED

Index.NOT_ANALYZED

Index.ANALYZED_NO_NORMS

Index.NOT_ANALYZED_NO_NORMS

Index.NO

不能被索引

Field options for storing fields

Field.Store.*

Store.YES

保存搜索结果,eg:URL, title, or database primary key

Store.NO

一般伴随着Index.ANALYZED字段出现,不关心之前的结果

CompressionTools

Field options for term vectors

Term vectors

TermVector.YES

TermVector.WITH_POSITIONS

TermVector.WITH_OFFSETS

TermVector.WITH_POSITIONS_OFFSETS

TermVector.NO

save none

Fields value

Reader

TokenStream

byte[]

二进制数据

Vector Space Model

Field option for sorting

要使结果可以排序,必须保证以下条件:

Multivalued fields

一个name,多个value的情况

Document doc = new Document();
        for (String author : authors) {
          doc.add(new Field("author", author,
                            Field.Store.YES,
                            Field.Index.ANALYZED));
}

Store.YES

会保存多个Fields

上一篇 下一篇

猜你喜欢

热点阅读