Package org.hibernate.search.bridge
Interface LuceneOptions
public interface LuceneOptions
A helper class for building Field objects and associating them to Documents.
A wrapper class for Lucene parameters needed for indexing.
The recommended approach to index is to use
addFieldToDocument(String, String, org.apache.lucene.document.Document)
or addNumericFieldToDocument(String, Object, org.apache.lucene.document.Document) as all the options declared by
the user are transparently carried over. Compression is also provided transparently.
String fieldValue = convertToString(value);
luceneOptions.addFieldToDocument(name, fieldValue, document);
// Numeric
Double aDouble = ...
luceneOptions.addNumericFieldToDocument(name, value, document);
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddFieldToDocument(String fieldName, String indexedString, Document document) Add a new field with the namefieldNameto the Lucene Documentdocumentusing the valueindexedString.voidaddNumericFieldToDocument(String fieldName, Object numericValue, Document document) Add a new NumericField with the namefieldNameto the Lucene Documentdocumentusing the valuenumericValue.getBoost()Prefer the use ofaddFieldToDocument(String, String, org.apache.lucene.document.Document)over manually building your Field objects and adding them to the Document.getIndex()Prefer the use ofaddFieldToDocument(String, String, org.apache.lucene.document.Document)over manually building your Field objects and adding them to the Document.getStore()Prefer the use ofaddFieldToDocument(String, String, org.apache.lucene.document.Document)over manually building your Field objects and adding them to the Document.Prefer the use ofaddFieldToDocument(String, String, org.apache.lucene.document.Document)over manually building your Field objects and adding them to the Document.booleanPrefer the use ofaddFieldToDocument(String, String, org.apache.lucene.document.Document)over manually building your Field objects and adding them to the Document.
-
Method Details
-
addFieldToDocument
Add a new field with the namefieldNameto the Lucene Documentdocumentusing the valueindexedString. If the indexedString is null then the field is not added to the document. The field options are following the user declaration:- stored or not
- compressed or not
- what type of indexing strategy
- what type of term vector strategy
- Parameters:
fieldName- The field nameindexedString- The value to indexdocument- the document to which to add the the new field
-
addNumericFieldToDocument
Add a new NumericField with the namefieldNameto the Lucene Documentdocumentusing the valuenumericValue. If the value is not numeric then the field is not added to the document- Parameters:
fieldName- The name of the fieldnumericValue- The numeric value, either an Int, Long, Float or Doubledocument- the document to which to add the the new field
-
isCompressed
boolean isCompressed()Prefer the use ofaddFieldToDocument(String, String, org.apache.lucene.document.Document)over manually building your Field objects and adding them to the Document. To use compression either use #addFieldToDocument or refer to Lucene documentation to implement your own compression strategy.- Returns:
- the compression strategy declared by the user
trueif the field value is compressed,falseotherwise.
-
getStore
Field.Store getStore()Prefer the use ofaddFieldToDocument(String, String, org.apache.lucene.document.Document)over manually building your Field objects and adding them to the Document.org.apache.lucene.document.Field.Store.YESif the field is storedorg.apache.lucene.document.Field.Store.NOotherwise. To determine if the field must be compressed, useisCompressed(). Starting from version 3.3, Store.COMPRESS is no longer returned, useisCompressed()To use compression either use #addFieldToDocument or refer to Lucene documentation to implement your own compression strategy.- Returns:
- Returns the store strategy declared by the user
-
getIndex
Field.Index getIndex()Prefer the use ofaddFieldToDocument(String, String, org.apache.lucene.document.Document)over manually building your Field objects and adding them to the Document.- Returns:
- Returns the indexing strategy declared by the user
-
getTermVector
Field.TermVector getTermVector()Prefer the use ofaddFieldToDocument(String, String, org.apache.lucene.document.Document)over manually building your Field objects and adding them to the Document.- Returns:
- Returns the term vector strategy declared by the user
-
getBoost
Float getBoost()Prefer the use ofaddFieldToDocument(String, String, org.apache.lucene.document.Document)over manually building your Field objects and adding them to the Document.- Returns:
- Returns the boost factor declared by the user
-
indexNullAs
String indexNullAs()- Returns:
- Returns the string for indexing
nullvalues.nullis returned in case no null token has been specified.
-