Modifier and Type | Field and Description |
---|---|
protected static float |
DEFAULT_BOOST
The default boost for a lucene field: 1.0f.
|
protected List<org.apache.lucene.document.Fieldable> |
doNotUseInExcerpt
List of
FieldNames.FULLTEXT fields which should not be used in
an excerpt. |
protected IndexFormatVersion |
indexFormatVersion
Indicates index format for this node indexer.
|
protected IndexingConfiguration |
indexingConfig
The indexing configuration or
null if none is available. |
protected NamespaceMappings |
mappings
Namespace mappings to use for indexing.
|
protected NodeState |
node
The
NodeState of the node to index |
protected NamePathResolver |
resolver
Name and Path resolver.
|
protected ItemStateManager |
stateProvider
The persistent item state provider
|
protected boolean |
supportHighlighting
If set to
true the fulltext field is stored and and a term
vector is created with offset information. |
Constructor and Description |
---|
NodeIndexer(NodeState node,
ItemStateManager stateProvider,
NamespaceMappings mappings,
Executor executor,
org.apache.tika.parser.Parser parser)
Creates a new node indexer.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addBinaryValue(org.apache.lucene.document.Document doc,
String fieldName,
InternalValue internalValue)
Adds the binary value to the document as the named field.
|
protected void |
addBooleanValue(org.apache.lucene.document.Document doc,
String fieldName,
Object internalValue)
Adds the string representation of the boolean value to the document as
the named field.
|
protected void |
addCalendarValue(org.apache.lucene.document.Document doc,
String fieldName,
Calendar internalValue)
Adds the calendar value to the document as the named field.
|
protected void |
addDecimalValue(org.apache.lucene.document.Document doc,
String fieldName,
BigDecimal internalValue)
Adds the long value to the document as the named field.
|
protected void |
addDoubleValue(org.apache.lucene.document.Document doc,
String fieldName,
double internalValue)
Adds the double value to the document as the named field.
|
protected void |
addLength(org.apache.lucene.document.Document doc,
String propertyName,
InternalValue value)
Adds a
FieldNames.PROPERTY_LENGTHS field to document
with a named length value. |
protected void |
addLongValue(org.apache.lucene.document.Document doc,
String fieldName,
long internalValue)
Adds the long value to the document as the named field.
|
protected void |
addMVPName(org.apache.lucene.document.Document doc,
Name name)
Adds a
FieldNames.MVP field to doc with the resolved
name using the internal search index namespace mapping. |
protected void |
addNameValue(org.apache.lucene.document.Document doc,
String fieldName,
Name internalValue)
Adds the name value to the document as the named field.
|
protected void |
addNodeName(org.apache.lucene.document.Document doc,
String namespaceURI,
String localName)
Depending on the index format version adds one or two fields to the
document for the node name.
|
protected void |
addParentChildRelation(org.apache.lucene.document.Document doc,
NodeId parentId)
Adds a parent child relation to the given
doc . |
protected void |
addPathValue(org.apache.lucene.document.Document doc,
String fieldName,
Path internalValue)
Adds the path value to the document as the named field.
|
protected void |
addPropertyName(org.apache.lucene.document.Document doc,
Name name)
Adds the property name to the lucene _:PROPERTIES_SET field.
|
protected void |
addReferenceValue(org.apache.lucene.document.Document doc,
String fieldName,
NodeId internalValue,
boolean weak)
Adds the reference value to the document as the named field.
|
protected void |
addStringValue(org.apache.lucene.document.Document doc,
String fieldName,
String internalValue)
Deprecated.
Use
addStringValue(Document, String, Object, boolean) instead. |
protected void |
addStringValue(org.apache.lucene.document.Document doc,
String fieldName,
String internalValue,
boolean tokenized)
Adds the string value to the document both as the named field and
optionally for full text indexing if
tokenized is
true . |
protected void |
addStringValue(org.apache.lucene.document.Document doc,
String fieldName,
String internalValue,
boolean tokenized,
boolean includeInNodeIndex,
float boost)
Deprecated.
|
protected void |
addStringValue(org.apache.lucene.document.Document doc,
String fieldName,
String internalValue,
boolean tokenized,
boolean includeInNodeIndex,
float boost,
boolean useInExcerpt)
Adds the string value to the document both as the named field and
optionally for full text indexing if
tokenized is
true . |
protected void |
addURIValue(org.apache.lucene.document.Document doc,
String fieldName,
URI internalValue)
Adds the uri value to the document as the named field.
|
protected void |
addValue(org.apache.lucene.document.Document doc,
InternalValue value,
Name name)
Adds a value to the lucene Document.
|
protected void |
addValueProperty(org.apache.lucene.document.Document doc,
InternalValue value,
Name name,
String fieldName)
Adds a property related value to the lucene Document.
|
org.apache.lucene.document.Document |
createDoc()
Creates a lucene Document.
|
protected org.apache.lucene.document.Field |
createFieldWithoutNorms(String fieldName,
String internalValue,
int propertyType)
Creates a field of name
fieldName with the value of
internalValue . |
protected org.apache.lucene.document.Fieldable |
createFulltextField(InternalValue value,
org.apache.tika.metadata.Metadata metadata)
Deprecated.
|
protected org.apache.lucene.document.Fieldable |
createFulltextField(InternalValue value,
org.apache.tika.metadata.Metadata metadata,
boolean withNorms)
Creates a fulltext field for the reader
value . |
protected org.apache.lucene.document.Field |
createFulltextField(String value)
Deprecated.
|
protected org.apache.lucene.document.Field |
createFulltextField(String value,
boolean store,
boolean withOffsets)
Deprecated.
|
protected org.apache.lucene.document.Field |
createFulltextField(String value,
boolean store,
boolean withOffsets,
boolean withNorms)
Creates a fulltext field for the string
value . |
int |
getMaxExtractLength()
Returns the maximum number of characters to extract from binaries.
|
protected float |
getNodeBoost() |
NodeId |
getNodeId()
Returns the
NodeId of the indexed node. |
protected float |
getPropertyBoost(Name propertyName)
Returns the boost value for the given property name.
|
protected InternalValue |
getValue(Name name)
Utility method that extracts the first value of the named property
of the current node.
|
protected boolean |
isIncludedInNodeIndex(Name propertyName)
Returns
true if the property with the given name should also
be added to the node scope index. |
protected boolean |
isIndexed(Name propertyName)
Returns
true if the property with the given name should
be indexed. |
protected boolean |
isSupportedMediaType(String type)
Returns
true if the provided type is among the types
supported by the Tika parser we are using. |
void |
setIndexFormatVersion(IndexFormatVersion indexFormatVersion)
Sets the index format version
|
void |
setIndexingConfiguration(IndexingConfiguration config)
Sets the indexing configuration for this node indexer.
|
void |
setMaxExtractLength(int length)
Sets the maximum number of characters to extract from binaries.
|
void |
setSupportHighlighting(boolean b)
If set to
true additional information is stored in the index
to support highlighting using the rep:excerpt pseudo property. |
protected void |
throwRepositoryException(Exception e)
Wraps the exception
e into a RepositoryException
and throws the created exception. |
protected boolean |
useInExcerpt(Name propertyName)
Returns
true if the content of the property with the given
name should the used to create an excerpt. |
protected static final float DEFAULT_BOOST
protected final NodeState node
NodeState
of the node to indexprotected final ItemStateManager stateProvider
protected final NamespaceMappings mappings
protected final NamePathResolver resolver
protected IndexingConfiguration indexingConfig
null
if none is available.protected boolean supportHighlighting
true
the fulltext field is stored and and a term
vector is created with offset information.protected IndexFormatVersion indexFormatVersion
protected List<org.apache.lucene.document.Fieldable> doNotUseInExcerpt
FieldNames.FULLTEXT
fields which should not be used in
an excerpt.public NodeIndexer(NodeState node, ItemStateManager stateProvider, NamespaceMappings mappings, Executor executor, org.apache.tika.parser.Parser parser)
node
- the node state to index.stateProvider
- the persistent item state manager to retrieve properties.mappings
- internal namespace mappings.executor
- background task executor for text extractionparser
- parser for binary propertiespublic NodeId getNodeId()
NodeId
of the indexed node.NodeId
of the indexed node.public void setSupportHighlighting(boolean b)
true
additional information is stored in the index
to support highlighting using the rep:excerpt pseudo property.b
- true
to enable highlighting support.public void setIndexFormatVersion(IndexFormatVersion indexFormatVersion)
indexFormatVersion
- the index format versionpublic void setIndexingConfiguration(IndexingConfiguration config)
config
- the indexing configuration.public int getMaxExtractLength()
public void setMaxExtractLength(int length)
length
- maximum extraction lengthpublic org.apache.lucene.document.Document createDoc() throws RepositoryException
RepositoryException
- if an error occurs while reading property
values from the ItemStateProvider
.protected void throwRepositoryException(Exception e) throws RepositoryException
e
into a RepositoryException
and throws the created exception.e
- the base exception.RepositoryException
protected void addMVPName(org.apache.lucene.document.Document doc, Name name)
FieldNames.MVP
field to doc
with the resolved
name
using the internal search index namespace mapping.doc
- the lucene document.name
- the name of the multi-value property.protected void addValue(org.apache.lucene.document.Document doc, InternalValue value, Name name) throws RepositoryException
doc
- the document.value
- the internal jackrabbit value.name
- the name of the property.RepositoryException
protected void addValueProperty(org.apache.lucene.document.Document doc, InternalValue value, Name name, String fieldName) throws RepositoryException
length
for indexed fields.doc
- the document.value
- the internal jackrabbit value.name
- the name of the property.RepositoryException
protected void addPropertyName(org.apache.lucene.document.Document doc, Name name)
doc
- the document.name
- the name of the property.protected void addBinaryValue(org.apache.lucene.document.Document doc, String fieldName, InternalValue internalValue)
This implementation checks if this node
is of type nt:resource
and if that is the case, tries to extract text from the binary property
using the parser
.
doc
- The document to which to add the fieldfieldName
- The name of the field to addinternalValue
- The value for the field to add to the document.protected InternalValue getValue(Name name) throws ItemStateException
null
if the property does
not exist or contains no values.name
- property namenull
ItemStateException
- if the property can not be accessedprotected void addBooleanValue(org.apache.lucene.document.Document doc, String fieldName, Object internalValue)
doc
- The document to which to add the fieldfieldName
- The name of the field to addinternalValue
- The value for the field to add to the document.protected org.apache.lucene.document.Field createFieldWithoutNorms(String fieldName, String internalValue, int propertyType)
fieldName
with the value of
internalValue
. The created field is indexed without norms.fieldName
- The name of the field to addinternalValue
- The value for the field to add to the document.propertyType
- the property type.protected void addCalendarValue(org.apache.lucene.document.Document doc, String fieldName, Calendar internalValue)
DateField
class.doc
- The document to which to add the fieldfieldName
- The name of the field to addinternalValue
- The value for the field to add to the document.protected void addDoubleValue(org.apache.lucene.document.Document doc, String fieldName, double internalValue)
DoubleField
class.doc
- The document to which to add the fieldfieldName
- The name of the field to addinternalValue
- The value for the field to add to the document.protected void addLongValue(org.apache.lucene.document.Document doc, String fieldName, long internalValue)
LongField
class.doc
- The document to which to add the fieldfieldName
- The name of the field to addinternalValue
- The value for the field to add to the document.protected void addDecimalValue(org.apache.lucene.document.Document doc, String fieldName, BigDecimal internalValue)
LongField
class.doc
- The document to which to add the fieldfieldName
- The name of the field to addinternalValue
- The value for the field to add to the document.protected void addReferenceValue(org.apache.lucene.document.Document doc, String fieldName, NodeId internalValue, boolean weak)
FieldNames.WEAK_REFS
field
to the index if it is a weak reference.doc
- The document to which to add the fieldfieldName
- The name of the field to addinternalValue
- The value for the field to add to the document.weak
- Flag indicating whether it's a WEAKREFERENCE (true) or a REFERENCE (flase)protected void addPathValue(org.apache.lucene.document.Document doc, String fieldName, Path internalValue)
doc
- The document to which to add the fieldfieldName
- The name of the field to addinternalValue
- The value for the field to add to the document.protected void addURIValue(org.apache.lucene.document.Document doc, String fieldName, URI internalValue)
doc
- The document to which to add the fieldfieldName
- The name of the field to addinternalValue
- The value for the field to add to the document.protected void addStringValue(org.apache.lucene.document.Document doc, String fieldName, String internalValue)
addStringValue(Document, String, Object, boolean)
instead.doc
- The document to which to add the fieldfieldName
- The name of the field to addinternalValue
- The value for the field to add to the document.protected void addStringValue(org.apache.lucene.document.Document doc, String fieldName, String internalValue, boolean tokenized)
tokenized
is
true
.doc
- The document to which to add the fieldfieldName
- The name of the field to addinternalValue
- The value for the field to add to the document.tokenized
- If true
the string is also tokenized
and fulltext indexed.protected void addStringValue(org.apache.lucene.document.Document doc, String fieldName, String internalValue, boolean tokenized, boolean includeInNodeIndex, float boost)
addStringValue(Document, String, String, boolean, boolean, float, boolean)
instead.tokenized
is
true
.doc
- The document to which to add the fieldfieldName
- The name of the field to addinternalValue
- The value for the field to add to the
document.tokenized
- If true
the string is also
tokenized and fulltext indexed.includeInNodeIndex
- If true
the string is also
tokenized and added to the node scope fulltext
index.boost
- the boost value for this string field.protected void addStringValue(org.apache.lucene.document.Document doc, String fieldName, String internalValue, boolean tokenized, boolean includeInNodeIndex, float boost, boolean useInExcerpt)
tokenized
is
true
.doc
- The document to which to add the fieldfieldName
- The name of the field to addinternalValue
- The value for the field to add to the
document.tokenized
- If true
the string is also
tokenized and fulltext indexed.includeInNodeIndex
- If true
the string is also
tokenized and added to the node scope fulltext
index.boost
- the boost value for this string field.useInExcerpt
- If true
the string may show up in
an excerpt.protected void addNameValue(org.apache.lucene.document.Document doc, String fieldName, Name internalValue)
Name
and mapping the name space using the name space
mappings with which this class has been created.doc
- The document to which to add the fieldfieldName
- The name of the field to addinternalValue
- The value for the field to add to the document.protected org.apache.lucene.document.Field createFulltextField(String value)
createFulltextField(String, boolean, boolean, boolean)
instead.value
.value
- the string value.protected org.apache.lucene.document.Field createFulltextField(String value, boolean store, boolean withOffsets)
createFulltextField(String, boolean, boolean, boolean)
instead.value
.value
- the string value.store
- if the value of the field should be stored.withOffsets
- if a term vector with offsets should be stored.protected org.apache.lucene.document.Field createFulltextField(String value, boolean store, boolean withOffsets, boolean withNorms)
value
.value
- the string value.store
- if the value of the field should be stored.withOffsets
- if a term vector with offsets should be stored.withNorms
- if norm information should be added for this valueprotected org.apache.lucene.document.Fieldable createFulltextField(InternalValue value, org.apache.tika.metadata.Metadata metadata)
createFulltextField(InternalValue, Metadata, boolean)
instead.value
.value
- the binary valuemetadata
- document metatadataprotected org.apache.lucene.document.Fieldable createFulltextField(InternalValue value, org.apache.tika.metadata.Metadata metadata, boolean withNorms)
value
.value
- the binary valuemetadata
- document metatadatawithNorms
- if norm information should be added for this valueprotected boolean isIndexed(Name propertyName)
true
if the property with the given name should
be indexed. The default is to index all properties unless explicit
indexing configuration is specified. The jcr:primaryType
and jcr:mixinTypes
properties are always indexed for
correct node type resolution in queries.propertyName
- name of a property.true
if the property should be indexed;
false
otherwise.protected boolean isIncludedInNodeIndex(Name propertyName)
true
if the property with the given name should also
be added to the node scope index.propertyName
- the name of a property.true
if it should be added to the node scope index;
false
otherwise.protected boolean useInExcerpt(Name propertyName)
true
if the content of the property with the given
name should the used to create an excerpt.propertyName
- the name of a property.true
if it should be used to create an excerpt;
false
otherwise.protected boolean isSupportedMediaType(String type)
true
if the provided type is among the types
supported by the Tika parser we are using.type
- the type to check.protected float getPropertyBoost(Name propertyName)
propertyName
- the name of a property.protected float getNodeBoost()
node
state.protected void addLength(org.apache.lucene.document.Document doc, String propertyName, InternalValue value)
FieldNames.PROPERTY_LENGTHS
field to document
with a named length value.doc
- the lucene document.propertyName
- the property name.value
- the internal value.protected void addNodeName(org.apache.lucene.document.Document doc, String namespaceURI, String localName) throws NamespaceException
doc
- the lucene document.namespaceURI
- the namespace URI of the node name.localName
- the local name of the node.NamespaceException
protected void addParentChildRelation(org.apache.lucene.document.Document doc, NodeId parentId) throws ItemStateException, RepositoryException
doc
.doc
- the document.parentId
- the id of the parent node.ItemStateException
- if the parent node cannot be read.RepositoryException
- if the parent node does not have a child node
entry for the current node.Copyright © 2004–2024 The Apache Software Foundation. All rights reserved.