prefuse.data.search
Class KeywordSearchTupleSet

java.lang.Object
  extended by prefuse.data.tuple.AbstractTupleSet
      extended by prefuse.data.tuple.DefaultTupleSet
          extended by prefuse.data.search.SearchTupleSet
              extended by prefuse.data.search.KeywordSearchTupleSet
All Implemented Interfaces:
EventConstants, TupleSet

public class KeywordSearchTupleSet
extends SearchTupleSet

SearchTupleSet implementation that performs text searches on indexed Tuple data using the Lucene search engine. Lucene is an open source search engine supporting full text indexing and keyword search. Please refer to the Lucene web page for more information. Note that for this class to be used by prefuse applications, the Lucene classes must be included on the application classpath.

Version:
1.0
Author:
jeffrey heer
See Also:
SearchQueryBinding

Field Summary
protected  int m_id
           
protected  LuceneSearcher m_lucene
           
protected  IntObjectHashMap m_map
           
protected  java.lang.String m_query
           
protected  boolean m_storeTermVectors
           
 
Fields inherited from class prefuse.data.tuple.DefaultTupleSet
m_tuples
 
Fields inherited from interface prefuse.data.event.EventConstants
ALL_COLUMNS, DELETE, INSERT, UPDATE
 
Fields inherited from interface prefuse.data.tuple.TupleSet
EMPTY_ARRAY
 
Constructor Summary
KeywordSearchTupleSet()
          Creates a new KeywordSearchFocusSet using an in-memory search index.
KeywordSearchTupleSet(LuceneSearcher searcher)
          Creates a new TextSearchFocusSet with the given LuceneSearcher.
 
Method Summary
 void clear()
          Removes all search hits and clears out the index.
protected  org.apache.lucene.document.Document getDocument(int id, java.lang.String text)
          Create a Lucene Document instance with the given document ID and text.
 LuceneSearcher getLuceneSearcher()
          Get the LuceneSearcher instance used by this class.
protected  Tuple getMatchingTuple(org.apache.lucene.document.Document d)
          Return the Tuple matching the given Lucene Document, if any.
 java.lang.String getQuery()
          Returns the current search query, if any.
 IntObjectHashMap getTupleMap()
          Returns a copy of the mapping from Lucene document IDs to prefuse Tuple instances.
 void index(Tuple t, java.lang.String field)
          Index an individual Tuple field, so that it can be searched for.
 boolean isUnindexSupported()
          Returns false, as unindexing values is not currently supported.
 void search(java.lang.String query)
          Searches the indexed Tuple fields for matching keywords, using the Lucene search engine.
 void unindex(Tuple t, java.lang.String attrName)
          This method throws an exception, as unidexing is not supported.
 
Methods inherited from class prefuse.data.search.SearchTupleSet
addTuple, index, removeTuple
 
Methods inherited from class prefuse.data.tuple.DefaultTupleSet
addInternal, clearInternal, containsTuple, getTupleCount, removeInternal, setTuple, toArray, tuples
 
Methods inherited from class prefuse.data.tuple.AbstractTupleSet
addColumn, addColumn, addColumn, addColumn, addColumns, addPropertyChangeListener, addPropertyChangeListener, addTupleSetListener, fireTupleEvent, fireTupleEvent, fireTupleEvent, getClientProperty, isAddColumnSupported, putClientProperty, removePropertyChangeListener, removePropertyChangeListener, removeTupleSetListener, tuples, tuples
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_map

protected IntObjectHashMap m_map

m_query

protected java.lang.String m_query

m_lucene

protected LuceneSearcher m_lucene

m_storeTermVectors

protected boolean m_storeTermVectors

m_id

protected int m_id
Constructor Detail

KeywordSearchTupleSet

public KeywordSearchTupleSet()
Creates a new KeywordSearchFocusSet using an in-memory search index.


KeywordSearchTupleSet

public KeywordSearchTupleSet(LuceneSearcher searcher)
Creates a new TextSearchFocusSet with the given LuceneSearcher.

Parameters:
searcher - the LuceneSearcher to use.
Method Detail

getQuery

public java.lang.String getQuery()
Returns the current search query, if any.

Specified by:
getQuery in class SearchTupleSet
Returns:
the currently active search query

search

public void search(java.lang.String query)
Searches the indexed Tuple fields for matching keywords, using the Lucene search engine. Matching Tuples are available as the members of this TupleSet.

Specified by:
search in class SearchTupleSet
Parameters:
query - the query string to search for

getMatchingTuple

protected Tuple getMatchingTuple(org.apache.lucene.document.Document d)
Return the Tuple matching the given Lucene Document, if any.

Parameters:
d - the Document to lookup.
Returns:
the matching Tuple, or null if none.

index

public void index(Tuple t,
                  java.lang.String field)
Description copied from class: SearchTupleSet
Index an individual Tuple field, so that it can be searched for.

Specified by:
index in class SearchTupleSet
Parameters:
t - the Tuple
field - the data field to index
See Also:
SearchTupleSet.index(prefuse.data.Tuple, java.lang.String)

isUnindexSupported

public boolean isUnindexSupported()
Returns false, as unindexing values is not currently supported.

Specified by:
isUnindexSupported in class SearchTupleSet
Returns:
true if unindex is supported, false otherwise.
See Also:
SearchTupleSet.isUnindexSupported()

unindex

public void unindex(Tuple t,
                    java.lang.String attrName)
This method throws an exception, as unidexing is not supported.

Specified by:
unindex in class SearchTupleSet
Parameters:
t - the Tuple
attrName - the data field to unindex
Throws:
java.lang.UnsupportedOperationException
See Also:
SearchTupleSet.unindex(prefuse.data.Tuple, java.lang.String)

getDocument

protected org.apache.lucene.document.Document getDocument(int id,
                                                          java.lang.String text)
Create a Lucene Document instance with the given document ID and text.

Parameters:
id - the document ID
text - the text the Document should contain
Returns:
a new Lucene Document instance

getLuceneSearcher

public LuceneSearcher getLuceneSearcher()
Get the LuceneSearcher instance used by this class.

Returns:
returns the backing lucene searcher.

getTupleMap

public IntObjectHashMap getTupleMap()
Returns a copy of the mapping from Lucene document IDs to prefuse Tuple instances.

Returns:
a copy of the map from lucene doc IDs to prefuse Tuples.

clear

public void clear()
Removes all search hits and clears out the index.

Specified by:
clear in interface TupleSet
Overrides:
clear in class DefaultTupleSet
See Also:
TupleSet.clear()


Copyright © 2007 Regents of the University of California