lucene中Field简介

Lucene 6.1.0中存在的field种类如下(后缀是Field):

下面介绍几个常用的Field类型:

  • TextField

A field that is indexed and tokenized, without term vectors. For example this would be used on a 'body' field, that contains the bulk of a document's text.
  是一个会自动被索引和分词的字段。一般被用在文章的正文部分。

  • StringField

A field that is indexed but not tokenized: the entire String value is indexed as a single token. For example this might be used for a 'country' field or an 'id' field. If you also need to sort on this field, separately add a SortedDocValuesField to your document.
 StringField会被索引,但是不会被分词,即会被当作一个完整的token处理,一般用在“国家”或者“ID”.

  • StoredField

A field whose value is stored so that IndexSearcher.doc(int) and IndexReader.document() will return the field and its value.
  也就是一个默认会被存储的Field。

举个例子
(下面是对新闻数据进行索引的过程,数据存储在MySQL数据库中,title列存文章标题,content存正文,url存文章所在的链接,author是文章的作者)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值