org.gcube.search.datafusion.helpers
Class RecordHelper

java.lang.Object
  extended by org.gcube.search.datafusion.helpers.RecordHelper
All Implemented Interfaces:
Serializable

public class RecordHelper
extends Object
implements Serializable

Author:
Alex Antoniadis
See Also:
Serialized Form

Field Summary
static String ID_FIELD
           
static String objid
           
static String QUERY_FIELD
           
static String SCORE_FIELD
           
 
Constructor Summary
RecordHelper()
           
 
Method Summary
static String getQueryFieldContent(gr.uoa.di.madgik.grs.record.GenericRecord rec, String snippetField)
          Gets the payload of the snippetField from the rec.
static String getQuerySnippetFields(gr.uoa.di.madgik.grs.record.GenericRecord rec, List<String> snippetFields)
          Gets the payload from either the snippetFields or from the actual payload.
static Float getRank(gr.uoa.di.madgik.grs.record.GenericRecord rec)
          Get the score field from the rec
static String getRecordContentFromObjID(gr.uoa.di.madgik.grs.record.GenericRecord rec)
          Getis the actual content of the rec.
static String getRecordID(gr.uoa.di.madgik.grs.record.GenericRecord rec)
          Gets the record id from the record.
static String getSnippetPayload(gr.uoa.di.madgik.grs.record.GenericRecord rec, String snippetField)
          Gets the payload of the snippetField from the rec
static gr.uoa.di.madgik.grs.record.GenericRecord luceneToRSRecord(org.apache.lucene.document.Document doc, Set<String> fieldsName, Float score)
          Gets a GenericRecord from a lucene Document.
static void rsRecToLucene(org.apache.lucene.index.IndexWriter w, String id, gr.uoa.di.madgik.grs.record.GenericRecord rsRec, String queryField)
          Converts and stores a GenericRecord to lucene.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objid

public static final String objid
See Also:
Constant Field Values

QUERY_FIELD

public static final String QUERY_FIELD
See Also:
Constant Field Values

ID_FIELD

public static final String ID_FIELD
See Also:
Constant Field Values

SCORE_FIELD

public static final String SCORE_FIELD
See Also:
Constant Field Values
Constructor Detail

RecordHelper

public RecordHelper()
Method Detail

getRank

public static Float getRank(gr.uoa.di.madgik.grs.record.GenericRecord rec)
Get the score field from the rec

Parameters:
rec -
Returns:
rec score

getSnippetPayload

public static String getSnippetPayload(gr.uoa.di.madgik.grs.record.GenericRecord rec,
                                       String snippetField)
                                throws gr.uoa.di.madgik.grs.record.GRS2RecordDefinitionException,
                                       gr.uoa.di.madgik.grs.buffer.GRS2BufferException
Gets the payload of the snippetField from the rec

Parameters:
rec -
snippetField -
Returns:
rec payload
Throws:
gr.uoa.di.madgik.grs.record.GRS2RecordDefinitionException
gr.uoa.di.madgik.grs.buffer.GRS2BufferException

getRecordContentFromObjID

public static String getRecordContentFromObjID(gr.uoa.di.madgik.grs.record.GenericRecord rec)
                                        throws gr.uoa.di.madgik.grs.record.GRS2RecordDefinitionException,
                                               gr.uoa.di.madgik.grs.buffer.GRS2BufferException,
                                               MalformedURLException,
                                               IOException
Getis the actual content of the rec. It retrieves the page from the URI in objectID field and extracts the text. null is returned if not found

Parameters:
rec -
Returns:
actual content of rec or null if not found
Throws:
gr.uoa.di.madgik.grs.record.GRS2RecordDefinitionException
gr.uoa.di.madgik.grs.buffer.GRS2BufferException
MalformedURLException
IOException

getRecordID

public static String getRecordID(gr.uoa.di.madgik.grs.record.GenericRecord rec)
                          throws gr.uoa.di.madgik.grs.record.GRS2RecordDefinitionException,
                                 gr.uoa.di.madgik.grs.buffer.GRS2BufferException,
                                 MalformedURLException,
                                 IOException
Gets the record id from the record. 0 is returned if not found

Parameters:
rec -
Returns:
record id or 0 if not found
Throws:
gr.uoa.di.madgik.grs.record.GRS2RecordDefinitionException
gr.uoa.di.madgik.grs.buffer.GRS2BufferException
MalformedURLException
IOException

getQuerySnippetFields

public static String getQuerySnippetFields(gr.uoa.di.madgik.grs.record.GenericRecord rec,
                                           List<String> snippetFields)
                                    throws gr.uoa.di.madgik.grs.record.GRS2RecordDefinitionException,
                                           gr.uoa.di.madgik.grs.buffer.GRS2BufferException,
                                           MalformedURLException,
                                           IOException
Gets the payload from either the snippetFields or from the actual payload. The fields in snippetFields are examined one by one and then the actual payload. If snippet is found then the search stops. If no payload is found after search empty string is returned

Parameters:
rec -
snippetFields -
Returns:
snippet or empty string if not found
Throws:
gr.uoa.di.madgik.grs.record.GRS2RecordDefinitionException
gr.uoa.di.madgik.grs.buffer.GRS2BufferException
MalformedURLException
IOException

getQueryFieldContent

public static String getQueryFieldContent(gr.uoa.di.madgik.grs.record.GenericRecord rec,
                                          String snippetField)
                                   throws gr.uoa.di.madgik.grs.record.GRS2RecordDefinitionException,
                                          gr.uoa.di.madgik.grs.buffer.GRS2BufferException,
                                          MalformedURLException,
                                          IOException
Gets the payload of the snippetField from the rec. Currently the same as getSnippetPayload(gr.uoa.di.madgik.grs.record.GenericRecord, java.lang.String)

Parameters:
rec -
snippetField -
Returns:
payload of snippetField or null if not found
Throws:
gr.uoa.di.madgik.grs.record.GRS2RecordDefinitionException
gr.uoa.di.madgik.grs.buffer.GRS2BufferException
MalformedURLException
IOException

rsRecToLucene

public static void rsRecToLucene(org.apache.lucene.index.IndexWriter w,
                                 String id,
                                 gr.uoa.di.madgik.grs.record.GenericRecord rsRec,
                                 String queryField)
                          throws Exception
Converts and stores a GenericRecord to lucene. queryField is the field where the query will be performed later.

Parameters:
w -
id -
rsRec -
queryField -
Throws:
Exception

luceneToRSRecord

public static gr.uoa.di.madgik.grs.record.GenericRecord luceneToRSRecord(org.apache.lucene.document.Document doc,
                                                                         Set<String> fieldsName,
                                                                         Float score)
                                                                  throws Exception
Gets a GenericRecord from a lucene Document. fieldsName is a collection with all the fields that we want to project from the record. If a field is not contained in the record null is returned. Typically, all the records that are returned will have the same fieldsName which is the union of all the records that is constructed in feeding see IndexHelper.feedLucene(org.apache.lucene.store.Directory, java.util.Iterator, java.util.List, java.util.Set, int)

Parameters:
doc -
fieldsName -
score -
Returns:
GenericRecord from the lucene Document
Throws:
Exception


Copyright © 2013. All Rights Reserved.