简体   繁体   中英

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? 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 . 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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