com.impetus.kundera.index
Class DocumentIndexer

java.lang.Object
  extended by com.impetus.kundera.index.DocumentIndexer
All Implemented Interfaces:
Indexer
Direct Known Subclasses:
LuceneIndexer

public abstract class DocumentIndexer
extends Object
implements Indexer

The Class KunderaIndexer.

Author:
animesh.kumar

Field Summary
protected  org.apache.lucene.analysis.Analyzer analyzer
          The analyzer.
protected static String DEFAULT_SEARCHABLE_FIELD
          The Constant DEFAULT_SEARCHABLE_FIELD.
protected static int docNumber
          The doc number.
protected static String INDEX_NAME
          The INDEX_NAME.
private static org.slf4j.Logger LOG
          log for this class.
protected static String SUPERCOLUMN_INDEX
          The Constant SUPERCOLUMN_INDEX.
protected  org.apache.lucene.analysis.Tokenizer tokenizer
          The tokenizer.
private static long UUID
          The Constant UUID.
 
Constructor Summary
DocumentIndexer()
          Instantiates a new lucandra indexer.
 
Method Summary
protected  void addEntityClassToDocument(EntityMetadata metadata, Object object, org.apache.lucene.document.Document document)
          Prepare index document.
protected  void addEntityFieldsToDocument(EntityMetadata metadata, Object object, org.apache.lucene.document.Document document)
          Adds the index properties.
private  void addFieldToDocument(Object object, org.apache.lucene.document.Document document, Field field, String colName, String indexName)
          Index field.
protected  void addParentKeyToDocument(String parentId, org.apache.lucene.document.Document currentDoc, Class<?> clazz)
          Index parent key.
private  void addSuperColumnNameToDocument(String superColumnName, org.apache.lucene.document.Document currentDoc)
          Index super column name.
protected  void createSuperColumnDocument(EntityMetadata metadata, Object object, org.apache.lucene.document.Document currentDoc, Object embeddedObject, javax.persistence.metamodel.EmbeddableType superColumn)
          Index super column.
protected  String getCannonicalPropertyName(String indexName, String propertyName)
          Gets the cannonical property name.
protected  String getKunderaId(EntityMetadata metadata, Object id)
          Gets the kundera id.
protected abstract  void indexDocument(EntityMetadata metadata, org.apache.lucene.document.Document currentDoc)
          Index document.
protected  void indexSuperColumn(EntityMetadata metadata, Object object, org.apache.lucene.document.Document currentDoc, Object embeddedObject, javax.persistence.metamodel.EmbeddableType superColumn)
          Index super column.
protected  org.apache.lucene.document.Document prepareDocumentForSuperColumn(EntityMetadata metadata, Object object, String embeddedColumnName, String parentId, Class<?> clazz)
          Prepare document.
 Map<String,Object> search(String query, Class<?> parentClass, Class<?> childClass, Object entityId, int start, int count)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.impetus.kundera.index.lucene.Indexer
close, documentExistsInIndex, entityExistsInIndex, flush, index, index, search, unindex, update
 
Methods inherited from interface com.impetus.kundera.index.Indexer
index, search, unIndex
 

Field Detail

LOG

private static final org.slf4j.Logger LOG
log for this class.


INDEX_NAME

protected static final String INDEX_NAME
The INDEX_NAME.

See Also:
Constant Field Values

UUID

private static final long UUID
The Constant UUID.

See Also:
Constant Field Values

DEFAULT_SEARCHABLE_FIELD

protected static final String DEFAULT_SEARCHABLE_FIELD
The Constant DEFAULT_SEARCHABLE_FIELD.

See Also:
Constant Field Values

SUPERCOLUMN_INDEX

protected static final String SUPERCOLUMN_INDEX
The Constant SUPERCOLUMN_INDEX.

See Also:
Constant Field Values

docNumber

protected static int docNumber
The doc number.


analyzer

protected org.apache.lucene.analysis.Analyzer analyzer
The analyzer.


tokenizer

protected org.apache.lucene.analysis.Tokenizer tokenizer
The tokenizer.

Constructor Detail

DocumentIndexer

public DocumentIndexer()
Instantiates a new lucandra indexer.

Parameters:
analyzer - the analyzer
Method Detail

prepareDocumentForSuperColumn

protected org.apache.lucene.document.Document prepareDocumentForSuperColumn(EntityMetadata metadata,
                                                                            Object object,
                                                                            String embeddedColumnName,
                                                                            String parentId,
                                                                            Class<?> clazz)
Prepare document.

Parameters:
metadata - the metadata
object - the object
embeddedColumnName - the super column name
parentId - the parent id
clazz - the clazz
Returns:
the document

addParentKeyToDocument

protected void addParentKeyToDocument(String parentId,
                                      org.apache.lucene.document.Document currentDoc,
                                      Class<?> clazz)
Index parent key.

Parameters:
parentId - the parent id
currentDoc - the current doc
clazz - the clazz

createSuperColumnDocument

protected void createSuperColumnDocument(EntityMetadata metadata,
                                         Object object,
                                         org.apache.lucene.document.Document currentDoc,
                                         Object embeddedObject,
                                         javax.persistence.metamodel.EmbeddableType superColumn)
Index super column.

Parameters:
metadata - the metadata
object - the object
currentDoc - the current doc
embeddedObject - the embedded object
superColumn - the super column

indexSuperColumn

protected void indexSuperColumn(EntityMetadata metadata,
                                Object object,
                                org.apache.lucene.document.Document currentDoc,
                                Object embeddedObject,
                                javax.persistence.metamodel.EmbeddableType superColumn)
Index super column.

Parameters:
metadata - the metadata
object - the object
currentDoc - the current doc
embeddedObject - the embedded object
superColumn - the super column

addSuperColumnNameToDocument

private void addSuperColumnNameToDocument(String superColumnName,
                                          org.apache.lucene.document.Document currentDoc)
Index super column name.

Parameters:
superColumnName - the super column name
currentDoc - the current doc

addEntityFieldsToDocument

protected void addEntityFieldsToDocument(EntityMetadata metadata,
                                         Object object,
                                         org.apache.lucene.document.Document document)
Adds the index properties.

Parameters:
metadata - the metadata
object - the object
document - the document

addEntityClassToDocument

protected void addEntityClassToDocument(EntityMetadata metadata,
                                        Object object,
                                        org.apache.lucene.document.Document document)
Prepare index document.

Parameters:
metadata - the metadata
object - the object
document - the document

addFieldToDocument

private void addFieldToDocument(Object object,
                                org.apache.lucene.document.Document document,
                                Field field,
                                String colName,
                                String indexName)
Index field.

Parameters:
object - the object
document - the document
field - the field
colName - the col name
indexName - the index name

search

public Map<String,Object> search(String query,
                                 Class<?> parentClass,
                                 Class<?> childClass,
                                 Object entityId,
                                 int start,
                                 int count)
Specified by:
search in interface Indexer

getKunderaId

protected String getKunderaId(EntityMetadata metadata,
                              Object id)
Gets the kundera id.

Parameters:
metadata - the metadata
id - the id
Returns:
the kundera id

getCannonicalPropertyName

protected String getCannonicalPropertyName(String indexName,
                                           String propertyName)
Gets the cannonical property name.

Parameters:
indexName - the index name
propertyName - the property name
Returns:
the cannonical property name

indexDocument

protected abstract void indexDocument(EntityMetadata metadata,
                                      org.apache.lucene.document.Document currentDoc)
Index document.

Parameters:
metadata - the metadata
currentDoc - the current doc


Copyright © 2014. All Rights Reserved.