org.mmbase.module.lucene
Class MMBaseEntry

java.lang.Object
  extended by org.mmbase.module.lucene.MMBaseEntry
All Implemented Interfaces:
IndexEntry

public class MMBaseEntry
extends Object
implements IndexEntry

This defines how MMBase Nodes are added to Lucene documents. This also takes into account 'related' nodes, by using the 'sub definitions'.

Version:
$Id: MMBaseEntry.java 41955 2010-04-19 12:11:48Z michiel $
Author:
Pierre van Rooden, Michiel Meeuwissen

Field Summary
static DateFormat DATE_FORMAT
           
 
Constructor Summary
MMBaseEntry(Node node, Collection<IndexFieldDefinition> fields, boolean multiLevel, NodeManager elementManager, Step elementStep, Collection<IndexDefinition> subQueries)
           
 
Method Summary
protected  Set<String> addStandardKeys(Document document)
          Adds the standard keys 'number', 'owner', 'builder' and returns a set of the steps which still needs adding to the document.
(package private)  void addToIndexed(int number, String fieldName, String alias)
          Add a name of a node with the specified number as having been indexed (so it won't be attempted to index it again)
(package private)  String getFieldDataAsString(Map<String,?> data, String fieldName)
          Return the data of a field as a string.
 String getIdentifier()
          The identifier which can be used to retrieve this IndexEntry, and which should uniquely identify it.
 String getKey()
          Key to be used for 'sub-queries', this can be the same as IndexEntry.getIdentifier(), but this is not necessary.
protected  Node getNode(IndexFieldDefinition fd)
           
protected  String getRealField(IndexFieldDefinition fd)
           
 Collection<IndexDefinition> getSubDefinitions()
          Returns a Collection of 'sub definition', probably copied from the IndexDefinition which produces this entry.
 void index(Document document)
          Writes this index entry to a lucene Document.
(package private)  boolean isIndexed(int number, String fieldName, String alias)
          Returns true if a field of a node indicated by the number has already been indexed.
protected  boolean shouldIndex(IndexFieldDefinition fd)
           
protected  void storeData(Map<String,Object> map)
          Store data from field in a node into the cursor
(package private)  void storeFieldData(Map<String,Object> data, String fieldName, Object value)
          Store data for a field to index.
(package private)  void storeFieldTextData(Map<String,Object> data, String fieldName, String value)
          Store textual data for a field to index.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DATE_FORMAT

public static final DateFormat DATE_FORMAT
Constructor Detail

MMBaseEntry

MMBaseEntry(Node node,
            Collection<IndexFieldDefinition> fields,
            boolean multiLevel,
            NodeManager elementManager,
            Step elementStep,
            Collection<IndexDefinition> subQueries)
Method Detail

getIdentifier

public String getIdentifier()
Description copied from interface: IndexEntry
The identifier which can be used to retrieve this IndexEntry, and which should uniquely identify it.

Specified by:
getIdentifier in interface IndexEntry

getKey

public String getKey()
Description copied from interface: IndexEntry
Key to be used for 'sub-queries', this can be the same as IndexEntry.getIdentifier(), but this is not necessary.

Specified by:
getKey in interface IndexEntry

addStandardKeys

protected Set<String> addStandardKeys(Document document)
Adds the standard keys 'number', 'owner', 'builder' and returns a set of the steps which still needs adding to the document. The set contains 'null' if this is not a multilevel or the main step needs adding.


index

public void index(Document document)
Description copied from interface: IndexEntry
Writes this index entry to a lucene Document. This does not consider sub-definitions. This is done by Indexer using IndexEntry.getSubDefinitions()

Specified by:
index in interface IndexEntry

getSubDefinitions

public Collection<IndexDefinition> getSubDefinitions()
Description copied from interface: IndexEntry
Returns a Collection of 'sub definition', probably copied from the IndexDefinition which produces this entry.

Specified by:
getSubDefinitions in interface IndexEntry

getNode

protected Node getNode(IndexFieldDefinition fd)

getRealField

protected String getRealField(IndexFieldDefinition fd)

shouldIndex

protected boolean shouldIndex(IndexFieldDefinition fd)

storeData

protected void storeData(Map<String,Object> map)
Store data from field in a node into the cursor

Parameters:
map - The map of fieldName/value mappings

storeFieldTextData

void storeFieldTextData(Map<String,Object> data,
                        String fieldName,
                        String value)
Store textual data for a field to index. The data is merged with any text already stored for indexing if appropriate.

Parameters:
fieldname - the name of the field used for indexing (the 'as' name of a field where appropriate)
value - the textual value to index
data - The map of fieldName/value mappings

storeFieldData

void storeFieldData(Map<String,Object> data,
                    String fieldName,
                    Object value)
Store data for a field to index. Data is only stored if it doesn't exist yet for this field.

Parameters:
fieldname - the name of the field used for indexing (the 'as' name of a field where appropriate)
value - the value to index

getFieldDataAsString

String getFieldDataAsString(Map<String,?> data,
                            String fieldName)
Return the data of a field as a string.

Parameters:
fieldname - the name of the field used for indexing (the 'as' name of a field where appropriate)

addToIndexed

void addToIndexed(int number,
                  String fieldName,
                  String alias)
Add a name of a node with the specified number as having been indexed (so it won't be attempted to index it again)

Parameters:
number - the number of the node
fieldName - the name of the field
alias - the alias under which the field is indexed

isIndexed

boolean isIndexed(int number,
                  String fieldName,
                  String alias)
Returns true if a field of a node indicated by the number has already been indexed.

Parameters:
number - the number of the node
fieldName - the name of the field
alias - the alias under which the field is indexed

toString

public String toString()
Overrides:
toString in class Object


MMBase 2.0-SNAPSHOT - null