Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Issue with geospatial index #2121

Locked Answered by Rik0253
Rik0253 asked this question in Q&A
Discussion options

  • Laravel-mongodb Version: dev-develop
  • PHP Version: 7.4.2
  • laravel vertion 7.X

Description:

Steps to reproduce

  1. I have used the geospatial index as stated in document
  2. Having error while insertion "Can't extract geo keys"

Expected behaviour

Tell us what should happen

Actual behaviour

I am having the code as
$property->location = ['type'=>'Point','coordinates'=>[22.85,88.95]]
used schema as
$collection->geospatial('location','2dsphere');
i cant find what is wrong? please help

You must be logged in to vote

@divine thanks for replying.
As the latest version was not working. Now I used "jenssegers/mongodb": "^4" and updated the composer but same problem.
I have mongodb --version v3.6.3
This is the error I am getting
Can't extract geo keys: { _id: ObjectId('5f868fd3da8d1f75472157a2'), property_name: "Galwan House", user_id: 30, property_slug: "galwan-house", property_address_line_1: "dhdfhr", property_address_line_1_ar: null, property_address_line_2: null, property_address_line_2_ar: null, property_nearest_landmark: "dfhfd", property_nearest_landmark_ar: null, property_country: "India", property_state: "West Bengal", property_zipcode: "700063", property_location: { type: "Poin---134

I have cre...

Replies: 2 comments 3 replies

Comment options

Hello,

Why are you using dev-develop version?

Thanks!

You must be logged in to vote
0 replies
Comment options

@divine thanks for replying.
As the latest version was not working. Now I used "jenssegers/mongodb": "^4" and updated the composer but same problem.
I have mongodb --version v3.6.3
This is the error I am getting
Can't extract geo keys: { _id: ObjectId('5f868fd3da8d1f75472157a2'), property_name: "Galwan House", user_id: 30, property_slug: "galwan-house", property_address_line_1: "dhdfhr", property_address_line_1_ar: null, property_address_line_2: null, property_address_line_2_ar: null, property_nearest_landmark: "dfhfd", property_nearest_landmark_ar: null, property_country: "India", property_state: "West Bengal", property_zipcode: "700063", property_location: { type: "Poin---134

I have created the schema as
$table->index(['property_location' => '2dsphere']);
The way I am inserting the data is

$property->property_location = ["type" => "Point", "coordinates" => [$request->lng, $request->lat]];
$property->save();

what I am doing wrong?

Thanks in advance !!

You must be logged in to vote
3 replies
Comment options

I don't know why are you still trying to use version ^4, use 3.7 for L7.

Thanks!

Comment options

I changed the version to 3.7 then also same issue
jenssegers/mongodb v3.7.0 A MongoDB based Eloquent mod...

Thanks!!

Comment options

Basically you have error that says Can't extract geo keys. Check that you're validating coordinates before saving.

Thanks!

Answer selected by Rik0253
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2121 on October 13, 2020 18:06.

AltStyle によって変換されたページ (->オリジナル) /