初识lucene(二)

一、field说明

        对于一个文档来说有多个域,域也是对应的搜索模块。

二、field的

   1.一些子类

首先是一个不变的属性值,这类字段还有一个主要用途,就是可以用于对搜索的返回结果集排序或是按范围查询FloatField
DoubleField  
IntField
LongField

BinaryDocValuesField           
NumericDocValuesField
SortedDocValuesField
SortedSetDocValuesField

StoredField                                    整个域要存储的
StringField                                     是一个不需要分词,而直接用于索引的字符串
TextField                                       是一大块需要经过分词的文本

 2.基本使用格式

   StringField

StringField(String name, String value, Field.Store stored) 

   TextField

TextField(String name, Reader reader) 
Creates a new un-stored TextField with Reader value.
 


TextField(String name, String value, Field.Store store) 
Creates a new TextField with String value.
 


TextField(String name, TokenStream stream) 
Creates a new un-stored TextField with TokenStream value. 

  StoreField

StoredField(String name, byte[] value) 
Create a stored-only field with the given binary value.
 


StoredField(String name, byte[] value, int offset, int length) 
Create a stored-only field with the given binary value.
 


StoredField(String name, BytesRef value) 
Create a stored-only field with the given binary value.
 


StoredField(String name, double value) 
Create a stored-only field with the given double value.
 


StoredField(String name, float value) 
Create a stored-only field with the given float value.
 


StoredField(String name, int value) 
Create a stored-only field with the given integer value.
 


StoredField(String name, long value) 
Create a stored-only field with the given long value.
 


StoredField(String name, String value) 
Create a stored-only field with the given string value. 

 

DoubleFielt  数值类型的方法一直

DoubleField(String name, double value, Field.Store stored) 
Creates a stored or un-stored DoubleField with the provided value and default precisionStep NumericUtils.PRECISION_STEP_DEFAULT (4).
 


DoubleField(String name, double value, FieldType type) 
Expert: allows you to customize the FieldType. 

  DocValues的格式

BinaryDocValuesField(String name, BytesRef value) 
Create a new binary DocValues field.

 3.域的选项

      索引选项

   

Index.ANALYZED     域值被分解切能被搜索,对于普通的文本(正文,标题,摘要等)
Index.NOT_ANALYZED 能被搜索但是不被分解,用于精确匹配 日期了,人名了
Index.ANALYZED_NO_NORMS 进行分词但是不存储norms信息,这个norms中包括了创建索引的时间和权值等信息  
Index.NOT_ANALYZED_NO_NORMS 即不进行分词也不存储norms信息
Index.NO            对应不会被搜索

   存储选项

Store.YES    存储   小的信息
Store。NO  不存储 大的文本

 搭配

ANALYZEDYES文档标题和摘要
ANALYZEDNO文档正文
NOT_ANALYZEDYES标识符(主键、文件名),电话号码、身份证号,姓名,日期
NOT_ANALYZEDNO隐藏关键字
NOYES文档类型,数据库主键(不进行索引)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值