Hi, I'm working with Spring Data Neo4J, Neo4j 1.6.1 and the following model: @Indexed(indexName = "locationsindex") public class Location { @GraphId private Long id;
and I'm trying to write a Cypher query like: @Query("...") Location findByLatAndLong(final float latitude, final float longitude); I have tried several options and nothing seems to work; I'm now thinking that perhaps I should select the node by an index query (because I need to check both latitude and longitude). Any help is appreciated. Thanks. Eugen.
Yes, That sounds like a plan. Have you checked out the spatial support, with a Well Known Text property to hold the points? On Apr 14, 2012 1:20 PM, "Eugen Paraschiv" <hanrisel...@gmail.com> wrote:
> Hi, > I'm working with Spring Data Neo4J, Neo4j 1.6.1 and the following model: > @Indexed(indexName = "locationsindex") > public class Location { > @GraphId > private Long id;
> private float latitude; > private float longitude; > ... > } > and I'm trying to write a Cypher query like: > @Query("...") > Location findByLatAndLong(final float latitude, final float longitude); > I have tried several options and nothing seems to work; I'm now thinking > that perhaps I should select the node by an index query (because I need to > check both latitude and longitude). > Any help is appreciated. > Thanks. > Eugen.
> Yes, > That sounds like a plan. Have you checked out the spatial support, with a Well Known Text property to hold the points?
> On Apr 14, 2012 1:20 PM, "Eugen Paraschiv" <hanrisel...@gmail.com> wrote: > Hi, > I'm working with Spring Data Neo4J, Neo4j 1.6.1 and the following model: > @Indexed(indexName = "locationsindex") > public class Location { > @GraphId > private Long id;
> private float latitude; > private float longitude; > ... > } > and I'm trying to write a Cypher query like: > @Query("...") > Location findByLatAndLong(final float latitude, final float longitude); > I have tried several options and nothing seems to work; I'm now thinking that perhaps I should select the node by an index query (because I need to check both latitude and longitude). > Any help is appreciated. > Thanks. > Eugen.
Sorry, I shouldn't have used Location(lat,lng) necessarily - it can be any other entity with two floats (I'm not using the spring data geo support at the moment). So essentially it's not related to geospatial stuff - just a general entity and an general query retrieving it by 2 fields. I'm not exactly sure about the documentation helping all that much on this - what exactly is the example query I should be looking at? Thanks. Eugen.
> Yes, > That sounds like a plan. Have you checked out the spatial support, with a > Well Known Text property to hold the points? > On Apr 14, 2012 1:20 PM, "Eugen Paraschiv" <hanrisel...@gmail.com> wrote:
>> Hi, >> I'm working with Spring Data Neo4J, Neo4j 1.6.1 and the following model: >> @Indexed(indexName = "locationsindex") >> public class Location { >> @GraphId >> private Long id;
>> private float latitude; >> private float longitude; >> ... >> } >> and I'm trying to write a Cypher query like: >> @Query("...") >> Location findByLatAndLong(final float latitude, final float longitude); >> I have tried several options and nothing seems to work; I'm now thinking >> that perhaps I should select the node by an index query (because I need to >> check both latitude and longitude). >> Any help is appreciated. >> Thanks. >> Eugen.
On Saturday, April 14, 2012 5:46:55 PM UTC+3, Michael Hunger wrote:
> Yes, > That sounds like a plan. Have you checked out the spatial support, with a > Well Known Text property to hold the points? > On Apr 14, 2012 1:20 PM, "Eugen Paraschiv" <hanrisel...@gmail.com> wrote:
>> Hi, >> I'm working with Spring Data Neo4J, Neo4j 1.6.1 and the following model: >> @Indexed(indexName = "locationsindex") >> public class Location { >> @GraphId >> private Long id;
>> private float latitude; >> private float longitude; >> ... >> } >> and I'm trying to write a Cypher query like: >> @Query("...") >> Location findByLatAndLong(final float latitude, final float longitude); >> I have tried several options and nothing seems to work; I'm now thinking >> that perhaps I should select the node by an index query (because I need to >> check both latitude and longitude). >> Any help is appreciated. >> Thanks. >> Eugen.
Could you include an example of a query you have tried, and the result you expected?
Like you mention, you need an index lookup (or a node id) for Cypher to start from. It currently does not let you look globally for unindexed properties.
I'm not super familiar with the spring integration.. does the @indexed in the beginning of the entity mean all attributes are indexed?
> Sorry, I shouldn't have used Location(lat,lng) necessarily - it can be any > other entity with two floats (I'm not using the spring data geo support at > the moment). So essentially it's not related to geospatial stuff - just a > general entity and an general query retrieving it by 2 fields. > I'm not exactly sure about the documentation helping all that much on this > - what exactly is the example query I should be looking at? > Thanks. > Eugen.
> On Saturday, April 14, 2012 5:46:55 PM UTC+3, Michael Hunger wrote:
>> Yes, >> That sounds like a plan. Have you checked out the spatial support, with a >> Well Known Text property to hold the points? >> On Apr 14, 2012 1:20 PM, "Eugen Paraschiv" <hanrisel...@gmail.com> wrote:
>>> Hi, >>> I'm working with Spring Data Neo4J, Neo4j 1.6.1 and the following model: >>> @Indexed(indexName = "locationsindex") >>> public class Location { >>> @GraphId >>> private Long id;
>>> private float latitude; >>> private float longitude; >>> ... >>> } >>> and I'm trying to write a Cypher query like: >>> @Query("...") >>> Location findByLatAndLong(final float latitude, final float longitude); >>> I have tried several options and nothing seems to work; I'm now thinking >>> that perhaps I should select the node by an index query (because I need to >>> check both latitude and longitude). >>> Any help is appreciated. >>> Thanks. >>> Eugen.
> On Saturday, April 14, 2012 5:46:55 PM UTC+3, Michael Hunger wrote:
>> Yes, >> That sounds like a plan. Have you checked out the spatial support, with a >> Well Known Text property to hold the points? >> On Apr 14, 2012 1:20 PM, "Eugen Paraschiv" <hanrisel...@gmail.com> wrote:
>>> Hi, >>> I'm working with Spring Data Neo4J, Neo4j 1.6.1 and the following model: >>> @Indexed(indexName = "locationsindex") >>> public class Location { >>> @GraphId >>> private Long id;
>>> private float latitude; >>> private float longitude; >>> ... >>> } >>> and I'm trying to write a Cypher query like: >>> @Query("...") >>> Location findByLatAndLong(final float latitude, final float longitude); >>> I have tried several options and nothing seems to work; I'm now thinking >>> that perhaps I should select the node by an index query (because I need to >>> check both latitude and longitude). >>> Any help is appreciated. >>> Thanks. >>> Eugen.
> Sorry, I shouldn't have used Location(lat,lng) necessarily - it can be any other entity with two floats (I'm not using the spring data geo support at the moment). So essentially it's not related to geospatial stuff - just a general entity and an general query retrieving it by 2 fields. > I'm not exactly sure about the documentation helping all that much on this - what exactly is the example query I should be looking at? > Thanks. > Eugen.
>> Yes, >> That sounds like a plan. Have you checked out the spatial support, with a Well Known Text property to hold the points?
>> On Apr 14, 2012 1:20 PM, "Eugen Paraschiv" <hanrisel...@gmail.com> wrote: >> Hi, >> I'm working with Spring Data Neo4J, Neo4j 1.6.1 and the following model: >> @Indexed(indexName = "locationsindex") >> public class Location { >> @GraphId >> private Long id;
>> private float latitude; >> private float longitude; >> ... >> } >> and I'm trying to write a Cypher query like: >> @Query("...") >> Location findByLatAndLong(final float latitude, final float longitude); >> I have tried several options and nothing seems to work; I'm now thinking that perhaps I should select the node by an index query (because I need to check both latitude and longitude). >> Any help is appreciated. >> Thanks. >> Eugen.
>> Yes, >> That sounds like a plan. Have you checked out the spatial support, with a Well Known Text property to hold the points?
>> On Apr 14, 2012 1:20 PM, "Eugen Paraschiv" <hanrisel...@gmail.com> wrote: >> Hi, >> I'm working with Spring Data Neo4J, Neo4j 1.6.1 and the following model: >> @Indexed(indexName = "locationsindex") >> public class Location { >> @GraphId >> private Long id;
>> private float latitude; >> private float longitude; >> ... >> } >> and I'm trying to write a Cypher query like: >> @Query("...") >> Location findByLatAndLong(final float latitude, final float longitude); >> I have tried several options and nothing seems to work; I'm now thinking that perhaps I should select the node by an index query (because I need to check both latitude and longitude). >> Any help is appreciated. >> Thanks. >> Eugen.
Right, I had some trouble with the autogenerated queries (posted about it a while back) so I didn't even try - it works well, thanks. Is there a way to see the exact query that gets generated? On the query you suggested, that's fine if you have the values (100 and 200) but if you have arguments: Location findByLatAndLong(final float latitude, final float longitude); then using {0} and {1} INSIDE the query: @Query("START location=node:locationsindex(\"latitude:{0} AND longitude:{1}\") RETURN location") doesn't work. Thanks. Eugen.
On Mon, Apr 16, 2012 at 10:36 AM, Michael Hunger <
> Location findByLatitudeAndLongitude(final float latitude, final float >> longitude);
> Which auto-generates the query you need. (It uses the where-clause to > filter for the entities).
> You might index the properties (at least one, there is still a bug with > indexing two) then the query would use that to look up.
> Michael
> Am 15.04.2012 um 12:21 schrieb Eugen Paraschiv:
> Sorry, I shouldn't have used Location(lat,lng) necessarily - it can be any > other entity with two floats (I'm not using the spring data geo support at > the moment). So essentially it's not related to geospatial stuff - just a > general entity and an general query retrieving it by 2 fields. > I'm not exactly sure about the documentation helping all that much on this > - what exactly is the example query I should be looking at? > Thanks. > Eugen.
> On Saturday, April 14, 2012 5:46:55 PM UTC+3, Michael Hunger wrote:
>> Yes, >> That sounds like a plan. Have you checked out the spatial support, with a >> Well Known Text property to hold the points? >> On Apr 14, 2012 1:20 PM, "Eugen Paraschiv" <hanrisel...@gmail.com> wrote:
>>> Hi, >>> I'm working with Spring Data Neo4J, Neo4j 1.6.1 and the following model: >>> @Indexed(indexName = "locationsindex") >>> public class Location { >>> @GraphId >>> private Long id;
>>> private float latitude; >>> private float longitude; >>> ... >>> } >>> and I'm trying to write a Cypher query like: >>> @Query("...") >>> Location findByLatAndLong(final float latitude, final float longitude); >>> I have tried several options and nothing seems to work; I'm now thinking >>> that perhaps I should select the node by an index query (because I need to >>> check both latitude and longitude). >>> Any help is appreciated. >>> Thanks. >>> Eugen.
> On Saturday, April 14, 2012 5:46:55 PM UTC+3, Michael Hunger wrote:
>> Yes, >> That sounds like a plan. Have you checked out the spatial support, with a >> Well Known Text property to hold the points? >> On Apr 14, 2012 1:20 PM, "Eugen Paraschiv" <hanrisel...@gmail.com> wrote:
>>> Hi, >>> I'm working with Spring Data Neo4J, Neo4j 1.6.1 and the following model: >>> @Indexed(indexName = "locationsindex") >>> public class Location { >>> @GraphId >>> private Long id;
>>> private float latitude; >>> private float longitude; >>> ... >>> } >>> and I'm trying to write a Cypher query like: >>> @Query("...") >>> Location findByLatAndLong(final float latitude, final float longitude); >>> I have tried several options and nothing seems to work; I'm now thinking >>> that perhaps I should select the node by an index query (because I need to >>> check both latitude and longitude). >>> Any help is appreciated. >>> Thanks. >>> Eugen.
> Right, I had some trouble with the autogenerated queries (posted about it a while back) so I didn't even try - it works well, thanks. Is there a way to see the exact query that gets generated? > On the query you suggested, that's fine if you have the values (100 and 200) but if you have arguments: > Location findByLatAndLong(final float latitude, final float longitude); > then using {0} and {1} INSIDE the query: > @Query("START location=node:locationsindex(\"latitude:{0} AND longitude:{1}\") RETURN location") > doesn't work. > Thanks. > Eugen.
> On Mon, Apr 16, 2012 at 10:36 AM, Michael Hunger <michael.hun...@neotechnology.com> wrote: > Eugen,
> you should always be able to do something like:
>> Location findByLatitudeAndLongitude(final float latitude, final float longitude);
> Which auto-generates the query you need. (It uses the where-clause to filter for the entities).
> You might index the properties (at least one, there is still a bug with indexing two) then the query would use that to look up.
> Michael
> Am 15.04.2012 um 12:21 schrieb Eugen Paraschiv:
>> Sorry, I shouldn't have used Location(lat,lng) necessarily - it can be any other entity with two floats (I'm not using the spring data geo support at the moment). So essentially it's not related to geospatial stuff - just a general entity and an general query retrieving it by 2 fields. >> I'm not exactly sure about the documentation helping all that much on this - what exactly is the example query I should be looking at? >> Thanks. >> Eugen.
>>> Yes, >>> That sounds like a plan. Have you checked out the spatial support, with a Well Known Text property to hold the points?
>>> On Apr 14, 2012 1:20 PM, "Eugen Paraschiv" <hanrisel...@gmail.com> wrote: >>> Hi, >>> I'm working with Spring Data Neo4J, Neo4j 1.6.1 and the following model: >>> @Indexed(indexName = "locationsindex") >>> public class Location { >>> @GraphId >>> private Long id;
>>> private float latitude; >>> private float longitude; >>> ... >>> } >>> and I'm trying to write a Cypher query like: >>> @Query("...") >>> Location findByLatAndLong(final float latitude, final float longitude); >>> I have tried several options and nothing seems to work; I'm now thinking that perhaps I should select the node by an index query (because I need to check both latitude and longitude). >>> Any help is appreciated. >>> Thanks. >>> Eugen.
>>> Yes, >>> That sounds like a plan. Have you checked out the spatial support, with a Well Known Text property to hold the points?
>>> On Apr 14, 2012 1:20 PM, "Eugen Paraschiv" <hanrisel...@gmail.com> wrote: >>> Hi, >>> I'm working with Spring Data Neo4J, Neo4j 1.6.1 and the following model: >>> @Indexed(indexName = "locationsindex") >>> public class Location { >>> @GraphId >>> private Long id;
>>> private float latitude; >>> private float longitude; >>> ... >>> } >>> and I'm trying to write a Cypher query like: >>> @Query("...") >>> Location findByLatAndLong(final float latitude, final float longitude); >>> I have tried several options and nothing seems to work; I'm now thinking that perhaps I should select the node by an index query (because I need to check both latitude and longitude). >>> Any help is appreciated. >>> Thanks. >>> Eugen.
> Right, I had some trouble with the autogenerated queries (posted about it > a while back) so I didn't even try - it works well, thanks. Is there a way > to see the exact query that gets generated? > On the query you suggested, that's fine if you have the values (100 and > 200) but if you have arguments: > Location findByLatAndLong(final float latitude, final float longitude); > then using {0} and {1} INSIDE the query: > @Query("START location=node:locationsindex(\"latitude:{0} AND > longitude:{1}\") RETURN location") > doesn't work. > Thanks. > Eugen.
> On Mon, Apr 16, 2012 at 10:36 AM, Michael Hunger < > michael.hun...@neotechnology.com> wrote:
>> Eugen,
>> you should always be able to do something like:
>> Location findByLatitudeAndLongitude(final float latitude, final float >>> longitude);
>> Which auto-generates the query you need. (It uses the where-clause to >> filter for the entities).
>> You might index the properties (at least one, there is still a bug with >> indexing two) then the query would use that to look up.
>> Michael
>> Am 15.04.2012 um 12:21 schrieb Eugen Paraschiv:
>> Sorry, I shouldn't have used Location(lat,lng) necessarily - it can be >> any other entity with two floats (I'm not using the spring data geo support >> at the moment). So essentially it's not related to geospatial stuff - just >> a general entity and an general query retrieving it by 2 fields. >> I'm not exactly sure about the documentation helping all that much on >> this - what exactly is the example query I should be looking at? >> Thanks. >> Eugen.
>> On Saturday, April 14, 2012 5:46:55 PM UTC+3, Michael Hunger wrote:
>>> Am 14.04.2012 um 16:41 schrieb Peter Neubauer:
>>> Yes, >>> That sounds like a plan. Have you checked out the spatial support, with >>> a Well Known Text property to hold the points? >>> On Apr 14, 2012 1:20 PM, "Eugen Paraschiv" <hanrisel...@gmail.com> >>> wrote:
>>>> Hi, >>>> I'm working with Spring Data Neo4J, Neo4j 1.6.1 and the following >>>> model: >>>> @Indexed(indexName = "locationsindex") >>>> public class Location { >>>> @GraphId >>>> private Long id;
>>>> private float latitude; >>>> private float longitude; >>>> ... >>>> } >>>> and I'm trying to write a Cypher query like: >>>> @Query("...") >>>> Location findByLatAndLong(final float latitude, final float longitude); >>>> I have tried several options and nothing seems to work; I'm now >>>> thinking that perhaps I should select the node by an index query (because I >>>> need to check both latitude and longitude). >>>> Any help is appreciated. >>>> Thanks. >>>> Eugen.
>> On Saturday, April 14, 2012 5:46:55 PM UTC+3, Michael Hunger wrote:
>>> Am 14.04.2012 um 16:41 schrieb Peter Neubauer:
>>> Yes, >>> That sounds like a plan. Have you checked out the spatial support, with >>> a Well Known Text property to hold the points? >>> On Apr 14, 2012 1:20 PM, "Eugen Paraschiv" <hanrisel...@gmail.com> >>> wrote:
>>>> Hi, >>>> I'm working with Spring Data Neo4J, Neo4j 1.6.1 and the following >>>> model: >>>> @Indexed(indexName = "locationsindex") >>>> public class Location { >>>> @GraphId >>>> private Long id;
>>>> private float latitude; >>>> private float longitude; >>>> ... >>>> } >>>> and I'm trying to write a Cypher query like: >>>> @Query("...") >>>> Location findByLatAndLong(final float latitude, final float longitude); >>>> I have tried several options and nothing seems to work; I'm now >>>> thinking that perhaps I should select the node by an index query (because I >>>> need to check both latitude and longitude). >>>> Any help is appreciated. >>>> Thanks. >>>> Eugen.