Search result sorted by nearest city using longitude and latitude


(vallabh-2) #1

Dear All,

I want to develop functionality to display results sorted by nearest city
using latitude and longitude.

For ex,
I have default city selected lets says, London whose latitude and longitude
is 51.50015200,-0.12623600
So i want to display result from London sorted by nearest city.
All result is having latitude and longitude.

But i am unable to develop in elastic search.

Any suggestions will be highly appreciated.

Thanks,
Vallabh

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(David Pilato) #2

Are you looking for this? http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#_geo_distance_sorting

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 nov. 2013 à 07:10, vallabh@wcities.com a écrit :

Dear All,

I want to develop functionality to display results sorted by nearest city using latitude and longitude.

For ex,
I have default city selected lets says, London whose latitude and longitude is 51.50015200,-0.12623600
So i want to display result from London sorted by nearest city.
All result is having latitude and longitude.

But i am unable to develop in elastic search.

Any suggestions will be highly appreciated.

Thanks,
Vallabh

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(vallabh-2) #3

Thanks for the reply.
Basically, i wanted to search by latitude and longitude.

I am getting this data,

Array
(
[id] => 785629
[title] => test
[alias] => test
[state] => 1
[sectionid] => 1,
[catid] => 2,
[subcatid] => -1,
[created] => 2013-01-07 10:47:48
[created_by] => 119
[modified] => 2013-04-24 01:41:59
[modified_by] => 173
[cityid] => 5887
[latitude] => 19.18667600
[longitude] => 72.83363880
)

If i have selected city London (51.50015200,-0.12623600), then i should be
getting nearest result from london itself.

Below is my code,
$result = $es->search(array(
"query" => array(
"dis_max" => array(
"queries" => array(
0 => array(
"field" => array(
"title" => $search //search value
)
)
)
)
),
"from" => 0,
"size" => 100000
)
);

On Wednesday, November 6, 2013 12:09:23 PM UTC+5:30, David Pilato wrote:

Are you looking for this?
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#_geo_distance_sorting

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 nov. 2013 à 07:10, val...@wcities.com <javascript:> a écrit :

Dear All,

I want to develop functionality to display results sorted by nearest city
using latitude and longitude.

For ex,
I have default city selected lets says, London whose latitude and
longitude is 51.50015200,-0.12623600
So i want to display result from London sorted by nearest city.
All result is having latitude and longitude.

But i am unable to develop in elastic search.

Any suggestions will be highly appreciated.

Thanks,
Vallabh

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(David Pilato) #4

Could you illustrate your example by gisting a full curl recreation?

I think reading your code that you are not using geo_points in your mapping but I may be wrong.

A curl recreation should help to understand what you are doing and how.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 nov. 2013 à 11:20, vallabh@wcities.com a écrit :

Thanks for the reply.
Basically, i wanted to search by latitude and longitude.

I am getting this data,
Array
(
[id] => 785629
[title] => test
[alias] => test
[state] => 1
[sectionid] => 1,
[catid] => 2,
[subcatid] => -1,
[created] => 2013-01-07 10:47:48
[created_by] => 119
[modified] => 2013-04-24 01:41:59
[modified_by] => 173
[cityid] => 5887
[latitude] => 19.18667600
[longitude] => 72.83363880
)
If i have selected city London (51.50015200,-0.12623600), then i should be getting nearest result from london itself.

Below is my code,
$result = $es->search(array(
"query" => array(
"dis_max" => array(
"queries" => array(
0 => array(
"field" => array(
"title" => $search //search value
)
)
)
)
),
"from" => 0,
"size" => 100000
)
);

On Wednesday, November 6, 2013 12:09:23 PM UTC+5:30, David Pilato wrote:

Are you looking for this? http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#_geo_distance_sorting

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 nov. 2013 à 07:10, val...@wcities.com a écrit :

Dear All,

I want to develop functionality to display results sorted by nearest city using latitude and longitude.

For ex,
I have default city selected lets says, London whose latitude and longitude is 51.50015200,-0.12623600
So i want to display result from London sorted by nearest city.
All result is having latitude and longitude.

But i am unable to develop in elastic search.

Any suggestions will be highly appreciated.

Thanks,
Vallabh

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(vallabh-2) #5

Thanks for the quick suggestions,

I am new in elastic search and yes i am not using geo_points in mapping.

I have attached 2 files named,

  1. process_venue.sh - which is responsible for indexing and mapping.
  2. venue_display.php - Responsible for displaying the data when click on
    search button.

As stated previous my data is coming this way,

Array
(
[id] => 178014
[title] => Test
[alias] => test
[state] => 1
[sectionid] => 9,
[catid] => 111,,
[subcatid] => -1,,
[created] => 1999-11-30 00:00:00
[created_by] => 78
[modified] => 2013-04-24 01:41:59
[modified_by] => 173
[cityid] => 28
[latitude] => 45.49927930
[longitude] => 9.12125800
)

Array
(
[id] => 664009
[title] => Test,
[alias] => test
[state] => 1
[sectionid] => 9,
[catid] => 96,
[subcatid] => 219,
[created] => 2010-06-28 18:55:51
[created_by] => 204
[modified] => 0000-00-00 00:00:00
[modified_by] => 0
[cityid] => 80
[latitude] => 35.66904600
[longitude] => 139.70728060
)

Thanks,
Vallabh

On Wednesday, November 6, 2013 4:02:06 PM UTC+5:30, David Pilato wrote:

Could you illustrate your example by gisting a full curl recreation?

I think reading your code that you are not using geo_points in your
mapping but I may be wrong.

A curl recreation should help to understand what you are doing and how.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 nov. 2013 à 11:20, val...@wcities.com <javascript:> a écrit :

Thanks for the reply.
Basically, i wanted to search by latitude and longitude.

I am getting this data,

Array
(
[id] => 785629
[title] => test
[alias] => test
[state] => 1
[sectionid] => 1,
[catid] => 2,
[subcatid] => -1,
[created] => 2013-01-07 10:47:48
[created_by] => 119
[modified] => 2013-04-24 01:41:59
[modified_by] => 173
[cityid] => 5887
[latitude] => 19.18667600
[longitude] => 72.83363880
)

If i have selected city London (51.50015200,-0.12623600), then i should be
getting nearest result from london itself.

Below is my code,
$result = $es->search(array(
"query" => array(
"dis_max" => array(
"queries" => array(
0 => array(
"field" => array(
"title" => $search //search value
)
)
)
)
),
"from" => 0,
"size" => 100000
)
);

On Wednesday, November 6, 2013 12:09:23 PM UTC+5:30, David Pilato wrote:

Are you looking for this?
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#_geo_distance_sorting

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 nov. 2013 à 07:10, val...@wcities.com a écrit :

Dear All,

I want to develop functionality to display results sorted by nearest city
using latitude and longitude.

For ex,
I have default city selected lets says, London whose latitude and
longitude is 51.50015200,-0.12623600
So i want to display result from London sorted by nearest city.
All result is having latitude and longitude.

But i am unable to develop in elastic search.

Any suggestions will be highly appreciated.

Thanks,
Vallabh

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(David Pilato) #6

So you answered yourself to your questions I guess. If you want to use geo distance sorting then you have to use geo_points in your mapping and create documents with proper geo fields.

This should help as well: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-geo-point-type.html

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

6 novembre 2013 at 12:04:33, vallabh@wcities.com (vallabh@wcities.com) a écrit:

Thanks for the quick suggestions,

I am new in elastic search and yes i am not using geo_points in mapping.

I have attached 2 files named,

  1. process_venue.sh - which is responsible for indexing and mapping.
  2. venue_display.php - Responsible for displaying the data when click on search button.

As stated previous my data is coming this way,
Array
(
[id] => 178014
[title] => Test
[alias] => test
[state] => 1
[sectionid] => 9,
[catid] => 111,,
[subcatid] => -1,,
[created] => 1999-11-30 00:00:00
[created_by] => 78
[modified] => 2013-04-24 01:41:59
[modified_by] => 173
[cityid] => 28
[latitude] => 45.49927930
[longitude] => 9.12125800
)

Array
(
[id] => 664009
[title] => Test,
[alias] => test
[state] => 1
[sectionid] => 9,
[catid] => 96,
[subcatid] => 219,
[created] => 2010-06-28 18:55:51
[created_by] => 204
[modified] => 0000-00-00 00:00:00
[modified_by] => 0
[cityid] => 80
[latitude] => 35.66904600
[longitude] => 139.70728060
)

Thanks,
Vallabh

On Wednesday, November 6, 2013 4:02:06 PM UTC+5:30, David Pilato wrote:
Could you illustrate your example by gisting a full curl recreation?

I think reading your code that you are not using geo_points in your mapping but I may be wrong.

A curl recreation should help to understand what you are doing and how.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 nov. 2013 à 11:20, val...@wcities.com a écrit :

Thanks for the reply.
Basically, i wanted to search by latitude and longitude.

I am getting this data,
Array
(
[id] => 785629
[title] => test
[alias] => test
[state] => 1
[sectionid] => 1,
[catid] => 2,
[subcatid] => -1,
[created] => 2013-01-07 10:47:48
[created_by] => 119
[modified] => 2013-04-24 01:41:59
[modified_by] => 173
[cityid] => 5887
[latitude] => 19.18667600
[longitude] => 72.83363880
)
If i have selected city London (51.50015200,-0.12623600), then i should be getting nearest result from london itself.

Below is my code,
$result = $es->search(array(
"query" => array(
"dis_max" => array(
"queries" => array(
0 => array(
"field" => array(
"title" => $search //search value
)
)
)
)
),
"from" => 0,
"size" => 100000
)
);

On Wednesday, November 6, 2013 12:09:23 PM UTC+5:30, David Pilato wrote:
Are you looking for this? http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#_geo_distance_sorting

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 nov. 2013 à 07:10, val...@wcities.com a écrit :

Dear All,

I want to develop functionality to display results sorted by nearest city using latitude and longitude.

For ex,
I have default city selected lets says, London whose latitude and longitude is 51.50015200,-0.12623600
So i want to display result from London sorted by nearest city.
All result is having latitude and longitude.

But i am unable to develop in elastic search.

Any suggestions will be highly appreciated.

Thanks,
Vallabh

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

  • process_venue.sh, 1.2 KB
  • venue_display.php, 2.4 KB

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(vallabh) #7

Hey David,

Thanks for the quick response and suggestion.
But still unable to understand why results are not displaying.
I have attached my 2 files named process_venue.sh and venue_display.php,
Is it possible for you to tell me where i am actually wrong ?
I have also changed my fields to lan and lon

Array
(
[id] => 785629
[title] => test
[alias] => test
[state] => 1
[sectionid] => 1,
[catid] => 2,
[subcatid] => -1,
[created] => 2013-01-07 10:47:48
[created_by] => 119
[modified] => 2013-04-24 01:41:59
[modified_by] => 173
[cityid] => 5887
[lat] => 19.18667600
[lon] => 72.83363880
)

Thanks,
Vallabh

On Wednesday, November 6, 2013 4:44:24 PM UTC+5:30, David Pilato wrote:

So you answered yourself to your questions I guess. If you want to use geo
distance sorting then you have to use geo_points in your mapping and create
documents with proper geo fields.

This should help as well:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-geo-point-type.html

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr

6 novembre 2013 at 12:04:33, val...@wcities.com <javascript:> (
val...@wcities.com <javascript:>) a écrit:

Thanks for the quick suggestions,

I am new in elastic search and yes i am not using geo_points in mapping.

I have attached 2 files named,

  1. process_venue.sh - which is responsible for indexing and mapping.
  2. venue_display.php - Responsible for displaying the data when click on
    search button.

As stated previous my data is coming this way,

Array
(
[id] => 178014
[title] => Test
[alias] => test
[state] => 1
[sectionid] => 9,
[catid] => 111,,
[subcatid] => -1,,
[created] => 1999-11-30 00:00:00
[created_by] => 78
[modified] => 2013-04-24 01:41:59
[modified_by] => 173
[cityid] => 28
[latitude] => 45.49927930
[longitude] => 9.12125800
)

Array
(
[id] => 664009
[title] => Test,
[alias] => test
[state] => 1
[sectionid] => 9,
[catid] => 96,
[subcatid] => 219,
[created] => 2010-06-28 18:55:51
[created_by] => 204
[modified] => 0000-00-00 00:00:00
[modified_by] => 0
[cityid] => 80
[latitude] => 35.66904600
[longitude] => 139.70728060
)

Thanks,
Vallabh

On Wednesday, November 6, 2013 4:02:06 PM UTC+5:30, David Pilato wrote:

Could you illustrate your example by gisting a full curl recreation?

I think reading your code that you are not using geo_points in your
mapping but I may be wrong.

A curl recreation should help to understand what you are doing and how.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 nov. 2013 à 11:20, val...@wcities.com a écrit :

Thanks for the reply.
Basically, i wanted to search by latitude and longitude.

I am getting this data,

Array
(
[id] => 785629
[title] => test
[alias] => test
[state] => 1
[sectionid] => 1,
[catid] => 2,
[subcatid] => -1,
[created] => 2013-01-07 10:47:48
[created_by] => 119
[modified] => 2013-04-24 01:41:59
[modified_by] => 173
[cityid] => 5887
[latitude] => 19.18667600
[longitude] => 72.83363880
)

If i have selected city London (51.50015200,-0.12623600), then i should
be getting nearest result from london itself.

Below is my code,
$result = $es->search(array(
"query" => array(
"dis_max" => array(
"queries" => array(
0 => array(
"field" => array(
"title" => $search //search value
)
)
)
)
),
"from" => 0,
"size" => 100000
)
);

On Wednesday, November 6, 2013 12:09:23 PM UTC+5:30, David Pilato wrote:

Are you looking for this?
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#_geo_distance_sorting

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 nov. 2013 à 07:10, val...@wcities.com a écrit :

Dear All,

I want to develop functionality to display results sorted by nearest
city using latitude and longitude.

For ex,
I have default city selected lets says, London whose latitude and
longitude is 51.50015200,-0.12623600
So i want to display result from London sorted by nearest city.
All result is having latitude and longitude.

But i am unable to develop in elastic search.

Any suggestions will be highly appreciated.

Thanks,
Vallabh

You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.


  • process_venue.sh, 1.2 KB
  • venue_display.php, 2.4 KB

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(David Pilato) #8

I have no idea as your curl recreation does not show how your documents are formed.
Please don't attach files to threads but GIST your examples: http://www.elasticsearch.org/help

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

6 novembre 2013 at 15:35:05, Vallabh Bothre (vallabh.bothre@gmail.com) a écrit:

Hey David,

Thanks for the quick response and suggestion.
But still unable to understand why results are not displaying.
I have attached my 2 files named process_venue.sh and venue_display.php,
Is it possible for you to tell me where i am actually wrong ?
I have also changed my fields to lan and lon
Array
(
[id] => 785629
[title] => test
[alias] => test
[state] => 1
[sectionid] => 1,
[catid] => 2,
[subcatid] => -1,
[created] => 2013-01-07 10:47:48
[created_by] => 119
[modified] => 2013-04-24 01:41:59
[modified_by] => 173
[cityid] => 5887
[lat] => 19.18667600
[lon] => 72.83363880
)

Thanks,
Vallabh

On Wednesday, November 6, 2013 4:44:24 PM UTC+5:30, David Pilato wrote:
So you answered yourself to your questions I guess. If you want to use geo distance sorting then you have to use geo_points in your mapping and create documents with proper geo fields.

This should help as well: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-geo-point-type.html

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

6 novembre 2013 at 12:04:33, val...@wcities.com (val...@wcities.com) a écrit:

Thanks for the quick suggestions,

I am new in elastic search and yes i am not using geo_points in mapping.

I have attached 2 files named,

  1. process_venue.sh - which is responsible for indexing and mapping.
  2. venue_display.php - Responsible for displaying the data when click on search button.

As stated previous my data is coming this way,
Array
(
[id] => 178014
[title] => Test
[alias] => test
[state] => 1
[sectionid] => 9,
[catid] => 111,,
[subcatid] => -1,,
[created] => 1999-11-30 00:00:00
[created_by] => 78
[modified] => 2013-04-24 01:41:59
[modified_by] => 173
[cityid] => 28
[latitude] => 45.49927930
[longitude] => 9.12125800
)

Array
(
[id] => 664009
[title] => Test,
[alias] => test
[state] => 1
[sectionid] => 9,
[catid] => 96,
[subcatid] => 219,
[created] => 2010-06-28 18:55:51
[created_by] => 204
[modified] => 0000-00-00 00:00:00
[modified_by] => 0
[cityid] => 80
[latitude] => 35.66904600
[longitude] => 139.70728060
)

Thanks,
Vallabh

On Wednesday, November 6, 2013 4:02:06 PM UTC+5:30, David Pilato wrote:
Could you illustrate your example by gisting a full curl recreation?

I think reading your code that you are not using geo_points in your mapping but I may be wrong.

A curl recreation should help to understand what you are doing and how.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 nov. 2013 à 11:20, val...@wcities.com a écrit :

Thanks for the reply.
Basically, i wanted to search by latitude and longitude.

I am getting this data,
Array
(
[id] => 785629
[title] => test
[alias] => test
[state] => 1
[sectionid] => 1,
[catid] => 2,
[subcatid] => -1,
[created] => 2013-01-07 10:47:48
[created_by] => 119
[modified] => 2013-04-24 01:41:59
[modified_by] => 173
[cityid] => 5887
[latitude] => 19.18667600
[longitude] => 72.83363880
)
If i have selected city London (51.50015200,-0.12623600), then i should be getting nearest result from london itself.

Below is my code,
$result = $es->search(array(
"query" => array(
"dis_max" => array(
"queries" => array(
0 => array(
"field" => array(
"title" => $search //search value
)
)
)
)
),
"from" => 0,
"size" => 100000
)
);

On Wednesday, November 6, 2013 12:09:23 PM UTC+5:30, David Pilato wrote:
Are you looking for this? http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#_geo_distance_sorting

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 nov. 2013 à 07:10, val...@wcities.com a écrit :

Dear All,

I want to develop functionality to display results sorted by nearest city using latitude and longitude.

For ex,
I have default city selected lets says, London whose latitude and longitude is 51.50015200,-0.12623600
So i want to display result from London sorted by nearest city.
All result is having latitude and longitude.

But i am unable to develop in elastic search.

Any suggestions will be highly appreciated.

Thanks,
Vallabh

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(vallabh) #9

Thanks for helping me David!
Vallabh

On Wednesday, November 6, 2013 8:29:00 PM UTC+5:30, David Pilato wrote:

I have no idea as your curl recreation does not show how your documents
are formed.
Please don't attach files to threads but GIST your examples:
http://www.elasticsearch.org/help

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr

6 novembre 2013 at 15:35:05, Vallabh Bothre (vallabh...@gmail.com<javascript:>)
a écrit:

Hey David,

Thanks for the quick response and suggestion.
But still unable to understand why results are not displaying.
I have attached my 2 files named process_venue.sh and venue_display.php,
Is it possible for you to tell me where i am actually wrong ?
I have also changed my fields to lan and lon

Array
(
[id] => 785629
[title] => test
[alias] => test
[state] => 1
[sectionid] => 1,
[catid] => 2,
[subcatid] => -1,
[created] => 2013-01-07 10:47:48
[created_by] => 119
[modified] => 2013-04-24 01:41:59
[modified_by] => 173
[cityid] => 5887
[lat] => 19.18667600
[lon] => 72.83363880
)

Thanks,
Vallabh

On Wednesday, November 6, 2013 4:44:24 PM UTC+5:30, David Pilato wrote:

So you answered yourself to your questions I guess. If you want to use
geo distance sorting then you have to use geo_points in your mapping and
create documents with proper geo fields.

This should help as well:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-geo-point-type.html

 -- 

David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr

6 novembre 2013 at 12:04:33, val...@wcities.com (val...@wcities.com) a
écrit:

Thanks for the quick suggestions,

I am new in elastic search and yes i am not using geo_points in mapping.

I have attached 2 files named,

  1. process_venue.sh - which is responsible for indexing and mapping.
  2. venue_display.php - Responsible for displaying the data when click on
    search button.

As stated previous my data is coming this way,

Array
(
[id] => 178014
[title] => Test
[alias] => test
[state] => 1
[sectionid] => 9,
[catid] => 111,,
[subcatid] => -1,,
[created] => 1999-11-30 00:00:00
[created_by] => 78
[modified] => 2013-04-24 01:41:59
[modified_by] => 173
[cityid] => 28
[latitude] => 45.49927930
[longitude] => 9.12125800
)

Array
(
[id] => 664009
[title] => Test,
[alias] => test
[state] => 1
[sectionid] => 9,
[catid] => 96,
[subcatid] => 219,
[created] => 2010-06-28 18:55:51
[created_by] => 204
[modified] => 0000-00-00 00:00:00
[modified_by] => 0
[cityid] => 80
[latitude] => 35.66904600
[longitude] => 139.70728060
)

Thanks,
Vallabh

On Wednesday, November 6, 2013 4:02:06 PM UTC+5:30, David Pilato wrote:

Could you illustrate your example by gisting a full curl recreation?

I think reading your code that you are not using geo_points in your
mapping but I may be wrong.

A curl recreation should help to understand what you are doing and how.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 nov. 2013 à 11:20, val...@wcities.com a écrit :

Thanks for the reply.
Basically, i wanted to search by latitude and longitude.

I am getting this data,

Array
(
[id] => 785629
[title] => test
[alias] => test
[state] => 1
[sectionid] => 1,
[catid] => 2,
[subcatid] => -1,
[created] => 2013-01-07 10:47:48
[created_by] => 119
[modified] => 2013-04-24 01:41:59
[modified_by] => 173
[cityid] => 5887
[latitude] => 19.18667600
[longitude] => 72.83363880
)

If i have selected city London (51.50015200,-0.12623600), then i should
be getting nearest result from london itself.

Below is my code,
$result = $es->search(array(
"query" => array(
"dis_max" => array(
"queries" => array(
0 => array(
"field" => array(
"title" => $search //search value
)
)
)
)
),
"from" => 0,
"size" => 100000
)
);

On Wednesday, November 6, 2013 12:09:23 PM UTC+5:30, David Pilato wrote:

Are you looking for this?
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#_geo_distance_sorting

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 nov. 2013 à 07:10, val...@wcities.com a écrit :

Dear All,

I want to develop functionality to display results sorted by nearest
city using latitude and longitude.

For ex,
I have default city selected lets says, London whose latitude and
longitude is 51.50015200,-0.12623600
So i want to display result from London sorted by nearest city.
All result is having latitude and longitude.

But i am unable to develop in elastic search.

Any suggestions will be highly appreciated.

Thanks,
Vallabh

You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



  • process_venue.sh, 1.3 KB
  • venue_display.php, 3 KB

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #10