简体   繁体   English

Lucene的org.apache.lucene.document.Field类的方法使用

[英]Methods usage of org.apache.lucene.document.Field class of Lucene

I try to understand two methods of the title class ie Field. 我尝试了解标题类的两种方法,即字段。 Here is method which contains those two methods. 这是包含这两种方法的方法。

protected void addAnalyzedField(Document document, String fieldName, TokenStream tokenizer,
            boolean withNorms, boolean withTermFreqAndPositions) {
        Field field = new Field(fieldName, tokenizer);
        field.setOmitNorms(!withNorms);
        field.setOmitTermFreqAndPositions(!withTermFreqAndPositions);
        document.add(field);
    }

I was absolutely confused for field.setOmitNorms(boolean....) and field.setOmitTermFreqAndPositions(boolean....) that what these two methods really does? 我对field.setOmitNorms(boolean....)field.setOmitTermFreqAndPositions(boolean....)感到非常困惑,这两种方法的真正作用是什么? I was guessing that these method are used whether the field are omitted from/to indexing process. 我猜测这些方法是否用于索引过程中是否省略了字段。 Am I right? 我对吗?

Can anybody can show up with some practical scenarios? 有人可以出现一些实际情况吗?

Thanks. 谢谢。

If you only want to store the field without indexing, simply use StoredField . 如果只想存储字段而不建立索引,则只需使用StoredField即可 If other fields on the same document will get indexed and point to this document during the search, you will be able to retrieve the same value as you presented. 如果在搜索过程中同一文档上的其他字段将被索引并指向该文档,则您将能够检索与您显示的值相同的值。

Norms are explained here . 规范在这里解释。

Term frequencies allow to tell how many matching terms have been found in the index. 词频可以告诉您在索引中找到了多少个匹配词。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM