Thanks Rick, I will try out this code. For my use case, I don't mind the lack
of transactional state, though I can imagine there to be use cases where having
access to transactional state is requred. It would be nice if this somehow
would become part of the standard Neo4j API. Niels
> From: [email protected]
> To: [email protected]
> Date: Fri, 17 Jun 2011 05:34:05 -0700
> Subject: Re: [Neo4j] all values of a key-object pair
>
> Hi, Niels.
>
> Mattias just responded yesterday to me on a similar question. See below:
>
> Rick
> ======
> 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.
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On
> Behalf Of Niels Hoogeveen
> Sent: Friday, June 17, 2011 8:30 AM
> To: [email protected]
> Subject: [Neo4j] all values of a key-object pair
>
>
>
>
>
> I have run into the situation where I want to add key value pairs to the
> Lucene index, where I have no need to store the value in a property, but I
> would like to know which values are stored in the Lucene index for a given
> key-object pair. Use case: Loading Dbpedia in Neo4J, I load all entities and
> all redirects. Every entity has a unique URL, as does every redirect. URL's
> are stored in Lucene to look up the node that corresponds to an entity. I
> have no need to store redirects, neither as node nor as a String array
> property (one entity can have more than one redirect), instead I want to
> store the redirect URL in the Lucene index, pointing to the associated entity
> node. In certain cases, however, I would like to know the redirect URL's
> associated with a certain entity. So I would like to be able to retrieve the
> values stored in the Lucene index for a given key-object pair. Is this
> possible? If not with the current setup, would it be possible to add such
> functionality? Kind
re
> gards,Niels Hoogeveen
> _______________________________________________
> Neo4j mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
> _______________________________________________
> Neo4j mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user