Message from discussion
Help with near(can't find special index: 2d for: { geoLoc: { $near: [ 40.75412, -72.98157000000001 ] } })
Received: by 10.204.157.134 with SMTP id b6mr1042496bkx.5.1336189939194;
Fri, 04 May 2012 20:52:19 -0700 (PDT)
X-BeenThere: mongodb-user@googlegroups.com
Received: by 10.204.8.149 with SMTP id h21ls1281995bkh.3.gmail; Fri, 04 May
2012 20:52:03 -0700 (PDT)
Received: by 10.204.132.81 with SMTP id a17mr1040108bkt.4.1336189923571;
Fri, 04 May 2012 20:52:03 -0700 (PDT)
Received: by 10.204.132.81 with SMTP id a17mr1040107bkt.4.1336189923547;
Fri, 04 May 2012 20:52:03 -0700 (PDT)
Return-Path: <fabioeb...@gmail.com>
Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com [209.85.214.53])
by gmr-mx.google.com with ESMTPS id cs9si12427177bkb.3.2012.05.04.20.52.03
(version=TLSv1/SSLv3 cipher=OTHER);
Fri, 04 May 2012 20:52:03 -0700 (PDT)
Received-SPF: pass (google.com: domain of fabioeb...@gmail.com designates 209.85.214.53 as permitted sender) client-ip=209.85.214.53;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of fabioeb...@gmail.com designates 209.85.214.53 as permitted sender) smtp.mail=fabioeb...@gmail.com; dkim=pass header...@gmail.com
Received: by mail-bk0-f53.google.com with SMTP id jk13so3088012bkc.40
for <mongodb-user@googlegroups.com>; Fri, 04 May 2012 20:52:03 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:in-reply-to:references:from:date:message-id:subject:to
:content-type;
bh=fRvc3oM1Ma+EoAqMgqgypmiWupT6lJKOMOcXWQg07Vo=;
b=AlPFJCtNGiGqcu3VTl0Vubxn9CCBSA0ilGjP7idSQsFyPCLDG6fzRIV99ZUWbVXSv4
mceNRvqBiq5KQFFklAeQFE9gF+5kgMC90JXoVpoWEr3wT7nKVV6Ss+n2Z7EKUardZbGg
VJi5axjARJbAnRl/shPQ7JWislOM93sWh2z3XvdTa5vv+Rd0lO0pZiFO49hsHY0TKsTE
nbpXzbf+giYI/caOy4bjZVz+ReV00p6qhpN+cld6qECap5lPBJ4kLbFMjyNZXWo/vKMx
tEmegwaZAET3OgdOVWX+NbouSNcSzVBfqPef58DPdOQ7faVCpuCKXj30+XFeDQVGBakB
jR0Q==
Received: by 10.204.155.137 with SMTP id s9mr2953678bkw.103.1336189923304;
Fri, 04 May 2012 20:52:03 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.205.64.205 with HTTP; Fri, 4 May 2012 20:51:43 -0700 (PDT)
In-Reply-To: <3046577.80.1336189819654.JavaMail.geo-discussion-forums@pbcoz4>
References: <15538477.963.1336185470565.JavaMail.geo-discussion-forums@ynbv36> <3046577.80.1336189819654.JavaMail.geo-discussion-forums@pbcoz4>
From: Fabio Ebner <fabioeb...@gmail.com>
Date: Sat, 5 May 2012 00:51:43 -0300
Message-ID: <CABuOS-zKqdk0U9SS3JAPQHG=+d2x8dTODwWbVJ=VbU-=Yk0...@mail.gmail.com>
Subject: Re: [mongodb-user] Re: Help with near(can't find special index: 2d
for: { geoLoc: { $near: [ 40.75412, -72.98157000000001 ] } })
To: mongodb-user@googlegroups.com
Content-Type: multipart/alternative; boundary=000e0cdfd4d6bb260404bf41f524
--000e0cdfd4d6bb260404bf41f524
Content-Type: text/plain; charset=ISO-8859-1
Nice.. this work..
tks
2012/5/5 Nat <nat.lu...@gmail.com>
> try declaring @Indexed annotation as follows:
>
> @Entity("city")
> public class City {
>
> @Id
> private ObjectId cdCity;
> private String nmCity;
> @Indexed(IndexDirection.GEO2D)
>
> private double[] geoLoc;
> public City() {
> // TODO Auto-generated constructor stub
> }
> public City(String nmCity, double[] geoLoc) {
> this.nmCity = nmCity;
> this.geoLoc = geoLoc;
> }
>
> //gets and setters
> }
>
>
> On Saturday, 5 May 2012 10:37:50 UTC+8, FabioEbner wrote:
>>
>> Can, someone help me?? i'm trying to use .near but i always get this
>> error:
>>
>> can't find special index: 2d for: { geoLoc: { $near: [ 40.75412,
>>> -72.98157000000001 ] } }
>>>
>>
>> i start the mongo with MongoDir\bin\mongod --dbpath dbDir
>>
>> i use this method to add the citys:
>>
>> public void addVarias() throws Exception{
>> City c1 = new City("teste1'", new double[] {40.724220,-73.961470});
>> City c2 = new City("teste2'", new double[] {40.734220,-73.971470});
>> City c3 = new City("teste3'", new double[] {40.754220,-73.981470});
>> City c4 = new City("teste4'", new double[] {40.754220,-72.981470});
>> City c5 = new City("teste5'", new double[] {41.754220,-72.981470});
>> ds = ConexaoDao.getInstance().**getDatastore();
>> ds.save(c1);
>> ds.save(c2);
>> ds.save(c3);
>> ds.save(c4);
>> ds.save(c5);
>> ds.ensureIndexes();
>> }
>> And this to get
>>
>> ds = ConexaoDao.getInstance().**getDatastore();
>> List<City> cityList = ds.find(City.class).field("**
>> geoLoc").near(40.754120,-72.**981570, 100/111.12).asList();
>>
>>
>> and this is my City Object:
>> @Entity("city")
>> public class City {
>>
>> @Id
>> private ObjectId cdCity;
>> private String nmCity;
>> private double[] geoLoc;
>> public City() {
>> // TODO Auto-generated constructor stub
>> }
>> public City(String nmCity, double[] geoLoc) {
>> this.nmCity = nmCity;
>> this.geoLoc = geoLoc;
>> }
>>
>> //gets and setters
>> }
>>
> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/mongodb-user/-/PP1ioNaTDO4J.
>
> To post to this group, send email to mongodb-user@googlegroups.com.
> To unsubscribe from this group, send email to
> mongodb-user+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/mongodb-user?hl=en.
>
--000e0cdfd4d6bb260404bf41f524
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Nice.. this work..<div><br></div><div>tks<br><br><div class=3D"gmail_quote"=
>2012/5/5 Nat <span dir=3D"ltr"><<a href=3D"mailto:nat.lu...@gmail.com" =
target=3D"_blank">nat.lu...@gmail.com</a>></span><br><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex">
try declaring @Indexed annotation as follows:<div><br><div><div><div class=
=3D"im"><div>@Entity("city")</div><div>public class City {</div><=
div><br></div><div><span style=3D"white-space:pre-wrap"> </span>@Id</div><d=
iv>
<span style=3D"white-space:pre-wrap"> </span>private ObjectId cdCity;</div>=
<div><span style=3D"white-space:pre-wrap"> </span>private String nmCity;</d=
iv><div><span style=3D"white-space:pre-wrap"> </span></div></div><span styl=
e=3D"color:rgb(17,85,204);font-family:monospace;white-space:pre-wrap"> @=
Indexed(IndexDirection.GEO2D)</span><div class=3D"im">
<br><div><span style=3D"white-space:pre-wrap"> </span>private double[] geoL=
oc;</div><div><span style=3D"white-space:pre-wrap"> </span></div><div><span=
style=3D"white-space:pre-wrap"> </span>public City() {</div><div><span sty=
le=3D"white-space:pre-wrap"> </span>// TODO Auto-generated constructor stu=
b</div>
<div><span style=3D"white-space:pre-wrap"> </span>}</div><div><span style=
=3D"white-space:pre-wrap"> </span></div><div><span style=3D"white-space:pre=
-wrap"> </span>public City(String nmCity, double[] geoLoc) {</div><div><spa=
n style=3D"white-space:pre-wrap"> </span>this.nmCity =3D nmCity;</div>
<div><span style=3D"white-space:pre-wrap"> </span>this.geoLoc =3D geoLoc;<=
/div><div><span style=3D"white-space:pre-wrap"> </span>}</div></div></div><=
div><br></div><div>//gets and setters</div><div>}</div></div><div><div clas=
s=3D"h5">
<div><pre><font color=3D"#1155cc"><br></font></pre>On Saturday, 5 May 2012 =
10:37:50 UTC+8, FabioEbner wrote:<blockquote class=3D"gmail_quote" style=
=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"=
>Can, someone help me?? i'm trying to use .near =A0but i always get thi=
s error:<div>
<br></div><blockquote class=3D"gmail_quote" style=3D"margin-top:0px;margin-=
right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-=
left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">can&#=
39;t find special index: 2d for: { geoLoc: { $near: [ 40.75412, -72.9815700=
0000001 ] } }<br>
</blockquote><div><br></div><div>i start the mongo with MongoDir\bin\mongod=
--dbpath dbDir=A0</div><div><br></div><div>i use this method to add the ci=
tys:</div><div><br></div><div><div>public void addVarias() throws Exception=
{</div>
<div><span style=3D"white-space:pre-wrap"> </span>City c1 =3D new City(&qu=
ot;teste1'", new double[] {40.724220,-73.961470});</div><div><span=
style=3D"white-space:pre-wrap"> </span>City c2 =3D new City("teste2&=
#39;", new double[] {40.734220,-73.971470});</div>
<div><span style=3D"white-space:pre-wrap"> </span>City c3 =3D new City(&qu=
ot;teste3'", new double[] {40.754220,-73.981470});<span style=3D"w=
hite-space:pre-wrap"> </span></div><div><span style=3D"white-space:pre-wra=
p"> </span>City c4 =3D new City("teste4'", new double[] {40.=
754220,-72.981470});</div>
<div><span style=3D"white-space:pre-wrap"> </span>City c5 =3D new City(&qu=
ot;teste5'", new double[] {41.754220,-72.981470});</div><div><span=
style=3D"white-space:pre-wrap"> </span></div><div><span style=3D"white-sp=
ace:pre-wrap"> </span>ds =3D ConexaoDao.getInstance().<u></u>getDatastore(=
);</div>
<div><span style=3D"white-space:pre-wrap"> </span></div><div><span style=
=3D"white-space:pre-wrap"> </span>ds.save(c1);</div><div><span style=3D"wh=
ite-space:pre-wrap"> </span>ds.save(c2);</div><div><span style=3D"white-sp=
ace:pre-wrap"> </span>ds.save(c3);</div>
<div><span style=3D"white-space:pre-wrap"> </span>ds.save(c4);</div><div><=
span style=3D"white-space:pre-wrap"> </span>ds.save(c5);</div><div><span s=
tyle=3D"white-space:pre-wrap"> </span></div><div><span style=3D"white-spac=
e:pre-wrap"> </span>ds.ensureIndexes();</div>
<div><span style=3D"white-space:pre-wrap"> </span></div><div><span style=
=3D"white-space:pre-wrap"> </span>}</div></div><div>And this to get</div><d=
iv><br></div><div><div>ds =3D ConexaoDao.getInstance().<u></u>getDatastore(=
);</div>
<div><span style=3D"white-space:pre-wrap"> </span>List<City> cityLi=
st =3D ds.find(City.class).field("<u></u>geoLoc").near(40.754120,=
-72.<u></u>981570, 100/111.12).asList();</div></div><div><br></div><div><br=
>
</div><div>and this is my City Object:</div><div><div>@Entity("city&qu=
ot;)</div><div>public class City {</div><div><br></div><div><span style=3D"=
white-space:pre-wrap"> </span>@Id</div><div><span style=3D"white-space:pre-=
wrap"> </span>private ObjectId cdCity;</div>
<div><span style=3D"white-space:pre-wrap"> </span>private String nmCity;</d=
iv><div><span style=3D"white-space:pre-wrap"> </span></div><div><span style=
=3D"white-space:pre-wrap"> </span>private double[] geoLoc;</div><div><span =
style=3D"white-space:pre-wrap"> </span></div>
<div><span style=3D"white-space:pre-wrap"> </span>public City() {</div><div=
><span style=3D"white-space:pre-wrap"> </span>// TODO Auto-generated const=
ructor stub</div><div><span style=3D"white-space:pre-wrap"> </span>}</div><=
div>
<span style=3D"white-space:pre-wrap"> </span></div><div><span style=3D"whit=
e-space:pre-wrap"> </span>public City(String nmCity, double[] geoLoc) {</di=
v><div><span style=3D"white-space:pre-wrap"> </span>this.nmCity =3D nmCity=
;</div>
<div><span style=3D"white-space:pre-wrap"> </span>this.geoLoc =3D geoLoc;<=
/div><div><span style=3D"white-space:pre-wrap"> </span>}</div></div><div><b=
r></div><div>//gets and setters</div><div>}</div></blockquote></div></div><=
/div>
</div><div><div class=3D"h5">
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;mongodb-user" group.<br></div></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/d/msg/mongodb-user/-/PP1ioNaTDO4J" target=3D"_blank">https://groups.goog=
le.com/d/msg/mongodb-user/-/PP1ioNaTDO4J</a>.<div class=3D"HOEnZb"><div cla=
ss=3D"h5">
<br>=20
To post to this group, send email to <a href=3D"mailto:mongodb-user@googleg=
roups.com" target=3D"_blank">mongodb-user@googlegroups.com</a>.<br>
To unsubscribe from this group, send email to <a href=3D"mailto:mongodb-use=
r%2Bunsubscribe@googlegroups.com" target=3D"_blank">mongodb-user+unsubscrib=
e@googlegroups.com</a>.<br>
For more options, visit this group at <a href=3D"http://groups.google.com/g=
roup/mongodb-user?hl=3Den" target=3D"_blank">http://groups.google.com/group=
/mongodb-user?hl=3Den</a>.<br>
</div></div></blockquote></div><br></div>
--000e0cdfd4d6bb260404bf41f524--