SMILA (incubation) API documentation

org.eclipse.smila.search.lucene.index
Class IndexConnection

java.lang.Object
  extended by org.eclipse.smila.search.index.IndexConnection
      extended by org.eclipse.smila.search.lucene.index.IndexConnection

public class IndexConnection
extends IndexConnection

The Class IndexConnection.

Author:
August Georg Schmidt (BROX)

Field Summary
static java.lang.String DATE_FORMAT_PATTERN
          Date format pattern.
 
Constructor Summary
IndexConnection(java.lang.String indexName)
          The Constructor.
 
Method Summary
protected  void addHighlightAnnotation(IQueryExpression dQE, Record record, int fieldNo, java.lang.String attributeName, java.lang.String indexName)
          Adds a highlighting annotation on the given record and attribute
protected  void close()
          Close index connection.
 void deleteDocument(Id id)
          Delete document from index.
 void deleteDocument(java.lang.String key)
          Delete document from index.
 boolean docExists(Id id)
          Checks whether a document exists in index.
 boolean docExists(java.lang.String key)
          Checks whether a document exists in index.
 LuceneSearchResult doQuery(IQueryExpression queryExpression, int startPos)
          Execute search query.
 LuceneSearchResult doQueryCallback(IndexSearcher indexSearcher, DQueryExpression queryExpression, int startPos)
          Do query callback for DoQueryOperation.
protected  void encodeTextField(DTextField tf)
          
 Analyzer getAnalyzer()
          Get Analyzer.
protected  java.lang.String[] getResultValues(Id id, int fieldNo)
           
protected  void getResultValues(java.lang.String[] keys, int[] fields, java.lang.String[][] values)
          
 IQueryExpression getSimpleSearchQuery(DQuery dQuery)
          Transform a simple search to the corresponding advanced search.
protected  IQueryExpression getTestQueryExpression(java.lang.String text)
          
protected  void insertDateParameter(DDateField field, IDFParameter configParameter, java.lang.String config, java.lang.StringBuffer sb)
          
protected  void insertNumberParameter(DNumberField field, INFParameter configParameter, java.lang.String config, java.lang.StringBuffer sb)
          
protected  void insertTextParameter(DTextField field, ITFParameter configParameter, java.lang.String config, java.lang.StringBuffer sb)
          
protected  void isSupportedValue(int fieldNo, java.lang.Object value)
          
 void learnDocument(Blackboard blackboard, Id id, java.util.Map<java.lang.String,java.lang.Integer> attributeMapping, java.util.Map<java.lang.String,java.lang.Integer> attachmentMapping)
          Add a document to index.
 java.lang.String padNumField(java.lang.String text)
          Enclose number in a fixed length text to allow range search.
protected  void setLiteralValue(Literal literal, int fieldNo, java.lang.String value)
          Set the value of the given literal using the appropriate type method.
protected  void startBurstmode()
          Start burst mode.
protected  void stopBurstmode()
          Stop burst mode.
 void unlock()
          Unlocks a locked index.
 
Methods inherited from class org.eclipse.smila.search.index.IndexConnection
doQuery, doQuery, doTestQuery, getIndex, getName, validateQuery
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATE_FORMAT_PATTERN

public static final java.lang.String DATE_FORMAT_PATTERN
Date format pattern.

See Also:
Constant Field Values
Constructor Detail

IndexConnection

public IndexConnection(java.lang.String indexName)
                throws IndexException
The Constructor.

Parameters:
indexName - Index name.
Throws:
IndexException - Unable to create index connection.
Method Detail

close

protected void close()
Close index connection.

Specified by:
close in class IndexConnection
See Also:
IndexConnection.close()

docExists

public boolean docExists(java.lang.String key)
                  throws IndexException
Checks whether a document exists in index.

Specified by:
docExists in class IndexConnection
Parameters:
key - Key.
Returns:
Whether a document exists.
Throws:
IndexException - Unable to check the document exists in index.
See Also:
IndexConnection.docExists(java.lang.String)

docExists

public boolean docExists(Id id)
                  throws IndexException
Checks whether a document exists in index.

Specified by:
docExists in class IndexConnection
Parameters:
id - the Id
Returns:
Whether a document exists.
Throws:
IndexException - Unable to check the document exists in index.
See Also:
IndexConnection.docExists(org.eclipse.smila.datamodel.id.Id)

deleteDocument

public void deleteDocument(java.lang.String key)
                    throws IndexException
Delete document from index.

Specified by:
deleteDocument in class IndexConnection
Parameters:
key - Key.
Throws:
IndexException - Unable to delete document from index.
See Also:
IndexConnection.deleteDocument(java.lang.String)

deleteDocument

public void deleteDocument(Id id)
                    throws IndexException
Delete document from index.

Specified by:
deleteDocument in class IndexConnection
Parameters:
id - the Id
Throws:
IndexException - Unable to delete document from index.
See Also:
IndexConnection.deleteDocument(org.eclipse.smila.datamodel.id.Id)

learnDocument

public void learnDocument(Blackboard blackboard,
                          Id id,
                          java.util.Map<java.lang.String,java.lang.Integer> attributeMapping,
                          java.util.Map<java.lang.String,java.lang.Integer> attachmentMapping)
                   throws IndexException,
                          BlackboardAccessException
Add a document to index.

Specified by:
learnDocument in class IndexConnection
Parameters:
blackboard - the BlackboardService
id - the Id of the record to add.
attributeMapping - Map containing the attribute to FieldNo mapping
attachmentMapping - Map containing the attachment to FieldNo mapping
Throws:
IndexException - Unable to add document to index.
BlackboardAccessException - if errors occur accessing the Blackboard
See Also:
IndexConnection.learnDocument(org.eclipse.smila.blackboard.Blackboard, org.eclipse.smila.datamodel.id.Id, java.util.Map, java.util.Map)

padNumField

public java.lang.String padNumField(java.lang.String text)
Enclose number in a fixed length text to allow range search.

Parameters:
text - Number to pad.
Returns:
Padded number.

getAnalyzer

public Analyzer getAnalyzer()
Get Analyzer.

Returns:
Analyzer.

startBurstmode

protected void startBurstmode()
                       throws IndexException
Start burst mode.

Specified by:
startBurstmode in class IndexConnection
Throws:
IndexException - Unable to start burst mode.
See Also:
IndexConnection.startBurstmode()

stopBurstmode

protected void stopBurstmode()
                      throws IndexException
Stop burst mode.

Specified by:
stopBurstmode in class IndexConnection
Throws:
IndexException - Unable to stop burst mode.
See Also:
IndexConnection.stopBurstmode()

getSimpleSearchQuery

public IQueryExpression getSimpleSearchQuery(DQuery dQuery)
                                      throws IndexException,
                                             NodeTransformerException,
                                             TemplateException
Transform a simple search to the corresponding advanced search.

Specified by:
getSimpleSearchQuery in class IndexConnection
Parameters:
dQuery - Simple search.
Returns:
Advanced search.
Throws:
IndexException - Unable to get advanced search.
NodeTransformerException - Unable to perform node transformation.
TemplateException - Unable to apply template.
See Also:
#getSimpleSearchQuery(org.eclipse.smila.search.utils.search.DQuery)

doQuery

public LuceneSearchResult doQuery(IQueryExpression queryExpression,
                                  int startPos)
                           throws IndexException
Execute search query.

Specified by:
doQuery in class IndexConnection
Parameters:
queryExpression - Advanced search query.
startPos - Start position.
Returns:
Result.
Throws:
IndexException - Unable to perform search query.
See Also:
IndexConnection.doQuery(org.eclipse.smila.search.utils.advsearch.IQueryExpression, int)

doQueryCallback

public LuceneSearchResult doQueryCallback(IndexSearcher indexSearcher,
                                          DQueryExpression queryExpression,
                                          int startPos)
                                   throws XMLUtilsException,
                                          AdvSearchException,
                                          IndexException,
                                          java.io.IOException
Do query callback for DoQueryOperation. (I was too lazy to split correctly all functionality to operations and sometimes it call callback to original code).

Parameters:
indexSearcher - the index searcher
queryExpression - the query expression
startPos - the start pos
Returns:
the d result
Throws:
XMLUtilsException - the XML utils exception
AdvSearchException - the adv search exception
IndexException - the index exception
java.io.IOException - Signals that an I/O exception has occurred.

getTestQueryExpression

protected IQueryExpression getTestQueryExpression(java.lang.String text)
                                           throws IndexException

Specified by:
getTestQueryExpression in class IndexConnection
Parameters:
text - -
Returns:
IQueryExpression
Throws:
IndexException - -
See Also:
IndexConnection.getTestQueryExpression(java.lang.String)

insertTextParameter

protected void insertTextParameter(DTextField field,
                                   ITFParameter configParameter,
                                   java.lang.String config,
                                   java.lang.StringBuffer sb)

Specified by:
insertTextParameter in class IndexConnection
Parameters:
field - -
configParameter - -
config - -
sb - -
See Also:
IndexConnection.insertTextParameter(org.eclipse.smila.search.utils.search.DTextField, org.eclipse.smila.search.utils.search.ITFParameter, java.lang.String, java.lang.StringBuffer)

insertNumberParameter

protected void insertNumberParameter(DNumberField field,
                                     INFParameter configParameter,
                                     java.lang.String config,
                                     java.lang.StringBuffer sb)

Specified by:
insertNumberParameter in class IndexConnection
Parameters:
field - -
configParameter - -
config - -
sb - -
See Also:
#insertNumberParameter(org.eclipse.smila.search.utils.search.DNumberField, org.eclipse.smila.search.utils.search.INFParameter, java.lang.String, java.lang.StringBuffer)

insertDateParameter

protected void insertDateParameter(DDateField field,
                                   IDFParameter configParameter,
                                   java.lang.String config,
                                   java.lang.StringBuffer sb)

Specified by:
insertDateParameter in class IndexConnection
Parameters:
field - -
configParameter - -
config - -
sb - -
See Also:
#insertDateParameter(org.eclipse.smila.search.utils.search.DDateField, org.eclipse.smila.search.utils.search.IDFParameter, java.lang.String, java.lang.StringBuffer)

getResultValues

protected void getResultValues(java.lang.String[] keys,
                               int[] fields,
                               java.lang.String[][] values)
                        throws IndexException

Specified by:
getResultValues in class IndexConnection
Parameters:
keys - -
fields - -
values - -
Throws:
IndexException - -
See Also:
#getResultValues(java.lang.String[], int[], java.lang.String[][])

getResultValues

protected java.lang.String[] getResultValues(Id id,
                                             int fieldNo)
                                      throws IndexException
Specified by:
getResultValues in class IndexConnection
Throws:
IndexException

encodeTextField

protected void encodeTextField(DTextField tf)
                        throws IndexException

Specified by:
encodeTextField in class IndexConnection
Parameters:
tf - -
Throws:
IndexException - -
See Also:
IndexConnection.encodeTextField(org.eclipse.smila.search.utils.search.DTextField)

isSupportedValue

protected void isSupportedValue(int fieldNo,
                                java.lang.Object value)
                         throws IndexException

Specified by:
isSupportedValue in class IndexConnection
Parameters:
fieldNo - -
value - -
Throws:
IndexException - -
See Also:
IndexConnection.isSupportedValue(int, java.lang.Object)

setLiteralValue

protected void setLiteralValue(Literal literal,
                               int fieldNo,
                               java.lang.String value)
                        throws IndexException
Set the value of the given literal using the appropriate type method.

Specified by:
setLiteralValue in class IndexConnection
Parameters:
literal - the literal to set the value
fieldNo - the fieldNo
value - the string value
Throws:
IndexException - if any error occurs
See Also:
IndexConnection.setLiteralValue(Literal, int, String)

addHighlightAnnotation

protected void addHighlightAnnotation(IQueryExpression dQE,
                                      Record record,
                                      int fieldNo,
                                      java.lang.String attributeName,
                                      java.lang.String indexName)
                               throws IndexException
Adds a highlighting annotation on the given record and attribute

Specified by:
addHighlightAnnotation in class IndexConnection
Parameters:
dQE - the IQueryExpression
record - the Record
fieldNo - the fieldNo
attributeName - the name of the attribute
indexName - the name of the index
Throws:
IndexException - if any errorr occurs
See Also:
org.eclipse.smila.search.index.IndexConnection#addHighlightAnnotation(IQueryExpression, Record, fieldNo,String, String)

unlock

public void unlock()
            throws IndexException
Description copied from class: IndexConnection
Unlocks a locked index.

Specified by:
unlock in class IndexConnection
Throws:
IndexException - if any error occurs
See Also:
unlock()

SMILA (incubation) API documentation