org.apache.lucene.index

Java Code Examples for org.apache.lucene.index.IndexOptions

Example 4
Project: languagetool   File: EmptyLuceneIndexCreator.java View source code 6 votes
public static void main(String[] args) throws IOException {
if (args.length != 1) {
System.out.println("Usage: " + EmptyLuceneIndexCreator.class.getSimpleName() + " <indexPath>");
System.exit(1);
}
Analyzer analyzer = new StandardAnalyzer();
IndexWriterConfig config = new IndexWriterConfig(analyzer);
Directory directory = FSDirectory.open(new File(args[0]).toPath());
IndexWriter writer = new IndexWriter(directory, config); FieldType fieldType = new FieldType();
fieldType.setIndexOptions(IndexOptions.DOCS);
fieldType.setStored(true);
Field countField = new Field("totalTokenCount", String.valueOf(0), fieldType);
Document doc = new Document();
doc.add(countField);
writer.addDocument(doc); writer.close();
}
 
ES里,
first of all index_options & term_vectors are two totally different things. 
index_options are "options" for the index you are searching on, a 
datastructure that holds "terms" to document lists (posting lists). 
TermVectors are a datastructure that gives you the "terms" for a given 
document and in addition their position in the document as well as their 
start and end character offsets. Now the index (each field has such an 
index) holds a sorted list of terms and each term points to a posting list. 
these posting lists are a list of documents that contain the term. On the 
posting list you can also store information like frequencies (how often did 
term Y occur in document X -> useful for scoring) as well as "positions" 
(at which position did term Y occur in document X -> this is required fo 
phrase & span queries).

if you have for instance a field that you only use for filtering you don't 
need freqs and postions so documents only will do the job. In an index the 
position information is the biggest piece of data usually aside stored 
fields. If you don't do phrase queries or spans you don't need them at all 
so safe the disk space and improve perf by only use docs and freqs. In 
previous version it wasn't possible to have only freqs but no positions 
(index_options supersede omit_term_frequencies_and_positions) so this is an 
improvement overall since the most common usecase might only need freqs but 
no positions. 

 
附上一些选项:
1:term_vector
TermVector.YES: Only store number of occurrences.
TermVector.WITH_POSITIONS: Store number of occurrence and positions of terms, but no offset.
TermVector.WITH_OFFSETS: Store number of occurrence and offsets of terms, but no positions.
TermVector.WITH_POSITIONS_OFFSETS:number of occurrence and positions , offsets of terms.
TermVector.NO:Don't store any term vector information.
2: index_options
Allows to set the indexing options, possible values are docs (only doc numbers are indexed), freqs (doc numbers and term frequencies), and positions (doc numbers, term frequencies and positions). Defaults to positions for analyzed fields, and to docs for not_analyzed fields. It is also possible to set it to offsets (doc numbers, term frequencies, positions and offsets).
 
参考:https://lucene.apache.org/core/4_1_0/core/org/apache/lucene/index/FieldInfo.IndexOptions.html
http://elasticsearch.cn/question/119

lucene IndexOptions可以设置DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS DOCS,ES里也可以设置的更多相关文章

  1. ES里设置索引中倒排列表仅仅存文档ID——采用docs存储后可以降低pos文件和cfs文件大小

    index_options The index_options parameter controls what information is added to the inverted index, ...

  2. 在package.json里面的script设置环境变量,区分开发及生产环境。注意mac与windows的设置方式不一样

    在package.json里面的script设置环境变量,区分开发及生产环境. 注意mac与windows的设置方式不一样. "scripts": { "publish- ...

  3. 导航栏和里面的View设置的是同一颜色值,实际运行又不一样.

    导航栏和里面的View设置的是同一颜色值,实际运行又不一样.如何保证两者的颜色一致呢?  答案就是:( navigationBar.translucent = NO; )   去除 导航条的分割线(黑 ...

  4. 14.3.3 Locks Set by Different SQL Statements in InnoDB 不同的SQL语句在InnoDB里的锁设置

    14.3.3 Locks Set by Different SQL Statements in InnoDB 不同的SQL语句在InnoDB里的锁设置 locking read, 一个UPDATE,或 ...

  5. Ubuntu里字符编码设置

    Ubuntu里字符编码设置   Ubuntu系统在默认的状况下只支持中文UTF-8编码,但是我们写的一些文档,还有java代码编译时采用gbk编码.所以需要修改.步骤如下:  www.2cto.com ...

  6. spring里的事物设置

    有的人说事物在spring里设置有两种,其实事物设置在spring配置文件中共有五种方式:第一种方式:每个Bean都有一个代理第二种方式:所有Bean共享一个代理基类第三种方式:使用拦截器第四种方式: ...

  7. FL studio里的项目设置介绍

    FL studio作为具有众多音乐功能,能够制作多轨音频录制,排序和混音的一款专业软件,我们可以借助VST主机,灵活的调音台,高级MIDI和ReWire支持,来创建专业品质的各种音乐曲目. 而今天我们 ...

  8. Android ViewPager里的所有图片设置监听打开同一活动显示不同图片

    Android ViewPager里的所有图片设置监听请看前一文章 为了省时所以2层菜单只做一个点击任意图片后显示相应图片的活动 关键点是每个点击对应的图片如何传参给显示的活动 因为只启动一个活动,所 ...

  9. 在tomcat启动时解析xml文件,获取特定标签的属性值,并将属性值设置到静态变量里

    这里以解析hibernate.cfg.xml数据库配置信息为例,运用dom4j的解析方式来解析xml文件. 1.在javaWeb工程里新建一个java类,命名为GetXmlValue.java,为xm ...

随机推荐

  1. Django中ORM多对多表的操作

    自己创建第三张表建立多对多关系 表的创建 # 老师表和学生表可以是一个多对多的关系,建表时可以手动建立第三张表建立关联 class Student(models.Model): name = mode ...

  2. [LeetCode] 342. 4的幂 ☆(是否4 的幂)

    描述 给定一个整数 (32 位有符号整数),请编写一个函数来判断它是否是 4 的幂次方. 示例 1: 输入: 16输出: true示例 2: 输入: 5输出: false 进阶:你能不使用循环或者递归 ...

  3. Flutter——Radio组件、RadioListTile组件(单选按钮组件)

    Radio组件 Radio组件的常用属性: 属性 描述 value 单选的值 onChanged 改变时触发 activeColor 选中的颜色.背景颜色 groupValue 选择组的值 impor ...

  4. 利用 Python django 框架 输入汉字,数字,字符,等。。转成二维码!

    利用 Python django 框架 输入汉字,数字,字符,等..转成二维码! 模块必备:Python环境 + pillow  + qrcode 模块 核心代码import qrcode qr = ...

  5. 团队高效率协作开发的秘密武器-APIDOC

    团队高效率协作开发的秘密武器 1.前言 在团队协作开发中,不知道各位有没有遇到这样的问题: l 新人接手了项目代码,因没有项目文档,只能靠追踪路由,寻读代码分析业务逻辑 l 前端同学写好了页面,苦等后 ...

  6. java基础(3)---Scanner键盘输入

    1.使用scanner类: import java.util.Scanner; class ScannerTest{ public static void main( String[] args){ ...

  7. 神奇搜索算法A*

    A* A*是一种启发式搜索算法,又叫最佳图搜索算法. 何谓启发式搜索? 众所周知,计算机在执行搜索算法时是没开上帝视角的.因此,在搜索时,往往显得盲目,把所有可能的状态全部遍历,这种搜索我们统称盲目搜 ...

  8. redis在本地进行启动的方式

    第一种 使用cmd命令行进行过操作 在本地配置好redis之后,启动的话是比较简单的 1-首先打开cmd运行界面 2-定位到本地redis目录 3-运行命令redis-server.exe redis ...

  9. 【bzoj3238】差异 后缀树

    题目大意:给你一个字符串$S$,设$S_i$是串$S$第$i$长的后缀,求: $\sum\limits_{i=1}^{|S|} \sum\limits_{j=i+1}^{|S|} |S_i|+|S_j ...

  10. Spring Cloud Eureka 注册中心高可用机制

    一.Eureka 正常工作流程 Service 服务作为 Eureka Client 客户端需要在启动的时候就要向 Eureka Server 注册中心进行注册,并获取最新的服务列表数据. Eurek ...