org.gcube.search.datafusion.helpers
Class IndexHelper
java.lang.Object
org.gcube.search.datafusion.helpers.IndexHelper
- All Implemented Interfaces:
- Serializable
public class IndexHelper
- extends Object
- implements Serializable
- Author:
- Alex Antoniadis
- See Also:
- Serialized Form
|
Method Summary |
static Map<String,Long> |
feedLucene(org.apache.lucene.store.Directory index,
Iterator<PositionalRecordWrapper> iter,
List<String> snippetFields,
Set<String> fields,
int count)
Feeds the lucene index with (maximum count) records that are retrieved from the iter. |
static org.apache.lucene.store.Directory |
initializeIndex()
|
static org.apache.lucene.index.IndexWriter |
initializeIndexWriter(org.apache.lucene.store.Directory index)
|
static List<gr.uoa.di.madgik.grs.record.GenericRecord> |
multiget(List<RankedRecord> recs,
org.apache.lucene.store.Directory index,
Set<String> fieldsName)
Performs a multiget on the lucene index from the given list of RankedRecords |
static Map<String,Pair> |
rankDocuments(org.apache.lucene.store.Directory index,
String query,
int count)
|
static Map<String,Pair> |
rankDocuments(org.apache.lucene.store.Directory index,
String query,
int count,
int hitsCount)
Performs the query on the index and returns a map with key the id of the record and value a pair of score and lucene id (different from record id)
Obviously, the returned result is not sorted but it requires sorting on the score |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IndexHelper
public IndexHelper()
initializeIndex
public static org.apache.lucene.store.Directory initializeIndex()
throws IOException
- Throws:
IOException
initializeIndexWriter
public static org.apache.lucene.index.IndexWriter initializeIndexWriter(org.apache.lucene.store.Directory index)
throws IOException
- Throws:
IOException
rankDocuments
public static Map<String,Pair> rankDocuments(org.apache.lucene.store.Directory index,
String query,
int count)
throws org.apache.lucene.queryparser.classic.ParseException,
IOException
- Throws:
org.apache.lucene.queryparser.classic.ParseException
IOException
rankDocuments
public static Map<String,Pair> rankDocuments(org.apache.lucene.store.Directory index,
String query,
int count,
int hitsCount)
throws org.apache.lucene.queryparser.classic.ParseException,
IOException
- Performs the query on the index and returns a map with key the id of the record and value a pair of score and lucene id (different from record id)
Obviously, the returned result is not sorted but it requires sorting on the score
- Parameters:
index - query - count - hitsCount -
- Returns:
- map of recordIDs -> (score, luceneDocID)
- Throws:
org.apache.lucene.queryparser.classic.ParseException
IOException
multiget
public static List<gr.uoa.di.madgik.grs.record.GenericRecord> multiget(List<RankedRecord> recs,
org.apache.lucene.store.Directory index,
Set<String> fieldsName)
throws Exception
- Performs a multiget on the lucene index from the given list of
RankedRecords
- Parameters:
recs - index - fieldsName -
- Returns:
- list of
GenericRecords retrieved
- Throws:
Exception
feedLucene
public static Map<String,Long> feedLucene(org.apache.lucene.store.Directory index,
Iterator<PositionalRecordWrapper> iter,
List<String> snippetFields,
Set<String> fields,
int count)
throws Exception
- Feeds the lucene index with (maximum count) records that are retrieved from the iter. A payload field that will be used for querying later is generated either
from fields that exist in the snippetFields or by the actual content of the record (objectID).
Also, each fieldName that is faced in records from iter are is gathered to contstruct a union of all fields
from the (different type of) records in the iter. It returns a map that has recordID as key and (the initial) record position as value.
Initial record position is the position that the record had before fusion in its iterator.
- Parameters:
index - iter - snippetFields - fields - count -
- Returns:
- map recordID -> position
- Throws:
Exception
Copyright © 2013. All Rights Reserved.