I added some kind of example in the FAQ,
http://wiki.neo4j.org/content/FAQ#Checking_if_a_relationship_exists_between_two_nodes

2010/9/29 Mattias Persson <matt...@neotechnology.com>

> I think the python bindings doesn't have native support for the new index
> framework and it's completely separate from the normal indexing found in the
> python API. Maybe you could call java code directly, or write your own
> bindings for that... because it hasn't been done as far as my knowledge
> goes.
>
> An example a solution for your problem (java code):
>
>     IndexProvider provider = new LucenIndexProvider( graphDb ); //
> Instantiate once
>     RelationshipIndex index = provider.relationshipIndex( "myIndexName",
>           LuceneIndexProvider.EXACT_CONFIG );
>
>     // Index a relationship
>     Relationship calledRel = n2.createRelationshipTo( n1, CALLED );
>     calledRel.setProperty( "on", 1234567890 );
>     index.add( calledRel, "on", calledRel.getProperty( "on" ) );
>     ....
>     // Check if such a relationship exists
>     boolean exists = index.get( "on", 1234567890, n2, n1 ).getSingle() !=
> null;
>
>
> 2010/9/29 Francois Kassis <francois_kas...@hotmail.com>
>
> Thx  Arijit.
>> actually I am using latest version of neo4j python version.
>> so how to inistiate and use the lucene-index for relationships.
>> Currently I am indexing nodes like:
>>
>> nodesindex = graphdb.index("insertednodes", create=True)
>> graphdb.node(n1, name="hello")
>> nodesindex["hello"] = n1
>>
>> is this the same should be done with relationships?
>> THX in advance.
>> Francois
>>
>> --------------------------------------------------
>> From: <user-requ...@lists.neo4j.org>
>> Sent: Wednesday, September 29, 2010 1:00 PM
>> To: <user@lists.neo4j.org>
>> Subject: User Digest, Vol 42, Issue 56
>>
>> > Send User mailing list submissions to
>> > user@lists.neo4j.org
>> >
>> > To subscribe or unsubscribe via the World Wide Web, visit
>> > https://lists.neo4j.org/mailman/listinfo/user
>> > or, via email, send a message with subject or body 'help' to
>> > user-requ...@lists.neo4j.org
>> >
>> > You can reach the person managing the list at
>> > user-ow...@lists.neo4j.org
>> >
>> > When replying, please edit your Subject line so it is more specific
>> > than "Re: Contents of User digest..."
>> >
>> >
>> > Today's Topics:
>> >
>> >   1. Re:  How do I sort Lucene results by field value, and
>> >      numerical range queries ? (Mattias Persson)
>> >   2. Re:  How do I sort Lucene results by field value, and
>> >      numerical range queries ? (Andreas Ronge)
>> >   3. Re:  How to check if a relation already exists in neo4j graph
>> >      (Arijit Mukherjee)
>> >   4. Re:  How to check if a relation already exists in neo4j
>> >      (Francois Kassis)
>> >
>> >
>> > ----------------------------------------------------------------------
>> >
>> > Message: 1
>> > Date: Tue, 28 Sep 2010 23:22:44 +0200
>> > From: Mattias Persson <matt...@neotechnology.com>
>> > Subject: Re: [Neo4j] How do I sort Lucene results by field value, and
>> > numerical range queries ?
>> > To: Neo4j user discussions <user@lists.neo4j.org>
>> > Message-ID:
>> > <aanlktikop7xbn4+jjxtr4ds5f3v-sy479kh5-ugyi...@mail.gmail.com<aanlktikop7xbn4%2bjjxtr4ds5f3v-sy479kh5-ugyi...@mail.gmail.com>
>> >
>> > Content-Type: text/plain; charset=UTF-8
>> >
>> > I think there's a working version of it now... look at the tests for
>> more
>> > information:
>> >
>> https://svn.neo4j.org/laboratory/components/lucene-index/trunk/src/test/java/org/neo4j/index/impl/lucene/TestLuceneIndex.java(testSorting<https://svn.neo4j.org/laboratory/components/lucene-index/trunk/src/test/java/org/neo4j/index/impl/lucene/TestLuceneIndex.java%28testSorting>
>> ,
>> > testNumericValues).
>> > 2010/9/24 Mattias Persson <matt...@neotechnology.com>
>> >
>> >>
>> >>
>> >> 2010/9/24 Andreas Ronge <andreas.ro...@jayway.se>
>> >>
>> >> On Thu, Sep 23, 2010 at 7:50 PM, Mattias Persson
>> >>> <matt...@neotechnology.com> wrote:
>> >>> > 2010/9/23 Andreas Ronge <andreas.ro...@jayway.se>
>> >>> >
>> >>> >> That's really good news !
>> >>> >> Does it also work if it was not indexes as Strings ? ( so that we
>> can
>> >>> >> sort integers or floats without any padding)
>> >>> >> I guess that requires that neo4j-lucene adds NumericField instances
>> >>> >> to
>> >>> >> the lucene document.
>> >>> >>
>> >>> >
>> >>> > Exactly, I'm just working on a solution for that... I'm not sure it
>> >>> should
>> >>> > index all Integer, Long, Float, Double values implicitly as
>> >>> > NumericField
>> >>> > since those aren't searchable with a regular term query. Maybe do
>> >>> something
>> >>> > explicit like:
>> >>> >
>> >>> >    myIndex.add( entity, "age", new ValueContext(
>> >>> > 31 ).indexNumeric() );
>> >>> >    ...
>> >>> >    // Query integer range
>> >>> >    myIndex.query( NumericRangeQuery.newIntRange( "age", 30, 40,
>> true,
>> >>> false
>> >>> > ) );
>> >>> >    // And with sorting (quite verbose though)
>> >>> >    myIndex.query( new QueryContext( NumericRangeQuery.newIntRange(
>> >>> >        "age", 0, 100, true, true ) ).sort( new Sort( new SortField(
>> >>> "age",
>> >>> > SortField.INT ) ) ) );
>> >>> >
>> >>> > So that you must know what you're doing... would that be ok or any
>> >>> > other
>> >>> > better idea?
>> >>>
>> >>> I think it's great that we have access to the full lucene API in the
>> >>> QueryContext.
>> >>> I don't care if it's verbose since I will wrap it in a nice JRuby API
>> >>> :-)
>> >>> I've already started to document how my lucene sorting and range query
>> >>> API will look like in Neo4j.rb;
>> >>> http://github.com/andreasronge/neo4j/wiki/Lucene
>> >>> (I will specify both the field will be indexed as numerical and of
>> what
>> >>> type.)
>> >>>
>> >>
>> >> Great, so I'll try to get this going and make a commit when I get the
>> >> time
>> >> (almost working locally).
>> >>
>> >>
>> >> --
>> >> Mattias Persson, [matt...@neotechnology.com]
>> >> Hacker, Neo Technology
>> >> www.neotechnology.com
>> >>
>> >
>> >
>> >
>> > --
>> > Mattias Persson, [matt...@neotechnology.com]
>> > Hacker, Neo Technology
>> > www.neotechnology.com
>> >
>> >
>> > ------------------------------
>> >
>> > Message: 2
>> > Date: Tue, 28 Sep 2010 23:27:57 +0200
>> > From: Andreas Ronge <andreas.ro...@jayway.se>
>> > Subject: Re: [Neo4j] How do I sort Lucene results by field value, and
>> > numerical range queries ?
>> > To: Neo4j user discussions <user@lists.neo4j.org>
>> > Message-ID:
>> > <aanlktimq7drnfjjked27agx8otvobdmhfaspc4qzt...@mail.gmail.com>
>> > Content-Type: text/plain; charset=ISO-8859-1
>> >
>> > Thanks a lot !
>> >
>> > On Tue, Sep 28, 2010 at 11:22 PM, Mattias Persson
>> > <matt...@neotechnology.com> wrote:
>> >> I think there's a working version of it now... look at the tests for
>> more
>> >> information:
>> >>
>> https://svn.neo4j.org/laboratory/components/lucene-index/trunk/src/test/java/org/neo4j/index/impl/lucene/TestLuceneIndex.java(testSorting<https://svn.neo4j.org/laboratory/components/lucene-index/trunk/src/test/java/org/neo4j/index/impl/lucene/TestLuceneIndex.java%28testSorting>
>> ,
>> >> testNumericValues).
>> >> 2010/9/24 Mattias Persson <matt...@neotechnology.com>
>> >>
>> >>>
>> >>>
>> >>> 2010/9/24 Andreas Ronge <andreas.ro...@jayway.se>
>> >>>
>> >>> On Thu, Sep 23, 2010 at 7:50 PM, Mattias Persson
>> >>>> <matt...@neotechnology.com> wrote:
>> >>>> > 2010/9/23 Andreas Ronge <andreas.ro...@jayway.se>
>> >>>> >
>> >>>> >> That's really good news !
>> >>>> >> Does it also work if it was not indexes as Strings ? ( so that we
>> >>>> >> can
>> >>>> >> sort integers or floats without any padding)
>> >>>> >> I guess that requires that neo4j-lucene adds NumericField
>> instances
>> >>>> >> to
>> >>>> >> the lucene document.
>> >>>> >>
>> >>>> >
>> >>>> > Exactly, I'm just working on a solution for that... I'm not sure it
>> >>>> should
>> >>>> > index all Integer, Long, Float, Double values implicitly as
>> >>>> > NumericField
>> >>>> > since those aren't searchable with a regular term query. Maybe do
>> >>>> something
>> >>>> > explicit like:
>> >>>> >
>> >>>> > ? ?myIndex.add( entity, "age", new ValueContext(
>> >>>> > 31 ).indexNumeric() );
>> >>>> > ? ?...
>> >>>> > ? ?// Query integer range
>> >>>> > ? ?myIndex.query( NumericRangeQuery.newIntRange( "age", 30, 40,
>> true,
>> >>>> false
>> >>>> > ) );
>> >>>> > ? ?// And with sorting (quite verbose though)
>> >>>> > ? ?myIndex.query( new QueryContext( NumericRangeQuery.newIntRange(
>> >>>> > ? ? ? ?"age", 0, 100, true, true ) ).sort( new Sort( new SortField(
>> >>>> "age",
>> >>>> > SortField.INT ) ) ) );
>> >>>> >
>> >>>> > So that you must know what you're doing... would that be ok or any
>> >>>> > other
>> >>>> > better idea?
>> >>>>
>> >>>> I think it's great that we have access to the full lucene API in the
>> >>>> QueryContext.
>> >>>> I don't care if it's verbose since I will wrap it in a nice JRuby API
>> >>>> :-)
>> >>>> I've already started to document how my lucene sorting and range
>> query
>> >>>> API will look like in Neo4j.rb;
>> >>>> http://github.com/andreasronge/neo4j/wiki/Lucene
>> >>>> (I will specify both the field will be indexed as numerical and of
>> what
>> >>>> type.)
>> >>>>
>> >>>
>> >>> Great, so I'll try to get this going and make a commit when I get the
>> >>> time
>> >>> (almost working locally).
>> >>>
>> >>>
>> >>> --
>> >>> Mattias Persson, [matt...@neotechnology.com]
>> >>> Hacker, Neo Technology
>> >>> www.neotechnology.com
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> Mattias Persson, [matt...@neotechnology.com]
>> >> Hacker, Neo Technology
>> >> www.neotechnology.com
>> >> _______________________________________________
>> >> Neo4j mailing list
>> >> User@lists.neo4j.org
>> >> https://lists.neo4j.org/mailman/listinfo/user
>> >>
>> >
>> >
>> > ------------------------------
>> >
>> > Message: 3
>> > Date: Wed, 29 Sep 2010 12:29:52 +0530
>> > From: Arijit Mukherjee <ariji...@gmail.com>
>> > Subject: Re: [Neo4j] How to check if a relation already exists in
>> > neo4j graph
>> > To: Neo4j user discussions <user@lists.neo4j.org>
>> > Message-ID:
>> > <aanlktikrul+phpc=czftkdaqtrraghsmg2uzrh8lo...@mail.gmail.com>
>> > Content-Type: text/plain; charset=ISO-8859-1
>> >
>> > Hi Francois
>> >
>> > I posted a similar question about a month ago. Here's what Mattias said
>> in
>> > his reply:
>> >
>> > "Looping through relatiomships manually is the way to go. However
>> there's
>> > a
>> > new component in
>> > https://svn.neo4j.org/laboratory/components/lucene-index/ which can
>> index
>> > relationships and do fast lookups on whether or not a relationship (with
>> a
>> > certain attribute even) exists between two nodes.
>> >
>> > You'll need to go with the latest kernel then as well (as seen in
>> > https://svn.neo4j.org/laboratory/components/lucene-index/pom.xml)<https://svn.neo4j.org/laboratory/components/lucene-index/pom.xml%29>
>> ."
>> >
>> > You would probably be able to find that post in the mailing list
>> archives.
>> >
>> > Regards
>> > Arijit
>> >
>> > On 28 September 2010 14:23, Francois Kassis
>> > <francois_kas...@hotmail.com>wrote:
>> >
>> >>
>> >> Hi all,
>> >> I am using the python version of neo4j.
>> >> if i have n1, n2 as two nodes and KNOWS a relation between n1 and n2 in
>> a
>> >> graph.
>> >> n2.KNOWS(n1): How to check if there is a relation KNOWS between n1 and
>> >> n2?n2.MAILED(n1, on=123456789) and n2.MAILED(n1, on=987654321): How to
>> >> check
>> >> that MAILED already inserted between n1 and n2 with a proprety
>> >> on=987654321?
>> >>
>> >> THX in advance.
>> >> _______________________________________________
>> >> Neo4j mailing list
>> >> User@lists.neo4j.org
>> >> https://lists.neo4j.org/mailman/listinfo/user
>> >>
>> >
>> >
>> >
>> > --
>> > "And when the night is cloudy,
>> > There is still a light that shines on me,
>> > Shine on until tomorrow, let it be."
>> >
>> >
>> > ------------------------------
>> >
>> > Message: 4
>> > Date: Wed, 29 Sep 2010 12:35:11 +0300
>> > From: "Francois Kassis" <francois_kas...@hotmail.com>
>> > Subject: Re: [Neo4j] How to check if a relation already exists in
>> > neo4j
>> > To: <user@lists.neo4j.org>
>> > Message-ID: <snt117-ds69a90bd037fc62559b1bc8d...@phx.gbl>
>> > Content-Type: text/plain; format=flowed; charset="iso-8859-1";
>> > reply-type=original
>> >
>> > Hi again,
>> > Just to clear my request.
>> > Please I would like to know how to check if a relationship already
>> exists
>> > using the python version of neo4j.
>> > EX: n2.CALLED(n1, on=123456789)
>> >       n2.CALLED(n1, on=987654321)
>> > How to check that n2 already CALLED n1 on=123456789.
>> > THX in advence.
>> >
>> >
>> >> Message: 3
>> >> Date: Tue, 28 Sep 2010 11:53:00 +0300
>> >> From: Francois Kassis <francois_kas...@hotmail.com>
>> >> Subject: [Neo4j] How to check if a relation already exists in neo4j
>> >> graph
>> >> To: "user@lists.neo4j.org" <user@lists.neo4j.org>
>> >> Message-ID: <snt117-w4930c216010495edd5bf4f8d...@phx.gbl>
>> >> Content-Type: text/plain; charset="iso-8859-1"
>> >>
>> >>
>> >> Hi all,
>> >> I am using the python version of neo4j.
>> >> if i have n1, n2 as two nodes and KNOWS a relation between n1 and n2 in
>> a
>> >> graph.
>> >> n2.KNOWS(n1): How to check if there is a relation KNOWS between n1 and
>> >> n2?n2.MAILED(n1, on=123456789) and n2.MAILED(n1, on=987654321): How to
>> >> check that MAILED already inserted between n1 and n2 with a proprety
>> >> on=987654321?
>> >>
>> >> THX in advance.
>> >>
>> >> ------------------------------
>> >
>> >
>> >
>> >
>> > ------------------------------
>> >
>> > _______________________________________________
>> > User mailing list
>> > User@lists.neo4j.org
>> > https://lists.neo4j.org/mailman/listinfo/user
>> >
>> >
>> > End of User Digest, Vol 42, Issue 56
>> > ************************************
>> >
>> _______________________________________________
>> Neo4j mailing list
>> User@lists.neo4j.org
>> https://lists.neo4j.org/mailman/listinfo/user
>>
>
>
>
> --
> Mattias Persson, [matt...@neotechnology.com]
> Hacker, Neo Technology
> www.neotechnology.com
>



-- 
Mattias Persson, [matt...@neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com
_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to