Hi Rick,
you could probably get the keys from the IndexReader, like so:
// I'm in LuceneIndex now
public Iterable<String> getKeys()
{
IndexSearcherRef searcher = service.dataSource().getIndexSearcher(
identifier, true );
try
{
IndexReader reader = searcher.getSearcher().getIndexReader();
Collection<String> fieldNames = reader.getFieldNames(
FieldOption.ALL );
// Make a copy since we don't know if the result is final or not
Collection<String> result = new ArrayList<String>( fieldNames );
result.remove( KEY_DOC_ID );
result.remove( KEY_START_NODE_ID );
result.remove( KEY_END_NODE_ID );
return result;
}
finally
{
searcher.closeStrict();
}
}
This is a perhaps bit crude implementation and will only work on committed
stuff, not any transactional state. This is a start at least.
public Iterable<String> getValues( String key )
{
IndexSearcherRef searcher = service.dataSource().getIndexSearcher(
identifier, true );
try
{
IndexReader reader = searcher.getSearcher().getIndexReader();
Collection<String> result = new ArrayList<String>();
TermEnum terms = reader.terms( new Term( key ) );
do
{
result.add( terms.term().text() );
}
while ( terms.next() );
return result;
}
catch ( IOException e )
{
throw new RuntimeException( e );
}
finally
{
searcher.closeStrict();
}
}
Suffers from the same problem of transactional state and also doesn't
consider that values could be other types, f.ex. integers where the string
is a weird encoding of such a value.
2011/6/9 Rick Bullotta <[email protected]>
> We really need a way to query a list of all of the terms for a specific
> field/key name. Any thoughts on how we could extend the Index framework
> safely to do this?
> _______________________________________________
> Neo4j mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
>
--
Mattias Persson, [[email protected]]
Hacker, Neo Technology
www.neotechnology.com
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user