Elastic result search by text with nearest distance using latitude and longitude

Dear All,

I am using elastic for venue search in that i do have title, latitude and
longitude.
I have some what 4 lac data.

My concern is that i wanted to search the text which will produce the
relevant result with nearest distance.

Right now i am using "geo_distance"

you can see my below code so that you can come to know what i am using,

curl -X PUT 'http://localhost:9200/adminvenue/?pretty=true' -d '
{
"settings" : {
"analysis" : {
"analyzer" : {
"venue_analyzer" : {
"tokenizer" : "standard",
"filter" : ["standard", "lowercase", "venue_metaphone",
"asciifolding"]
}
},
"filter" : {
"venue_metaphone" : {
"type" : "phonetic",
"encoder" : "metaphone",
"replace" : false
}
}
}
}
}

curl -X PUT
'http://localhost:9200/adminvenue/jos_content/_mapping?pretty=true' -d '
{
"jos_content" : {
"properties" : {

  "title" : {
  "type": "string",
  "index_analyzer": "venue_analyzer",
  "search_analyzer": "venue_analyzer"
  },
  "location" : {

"type" : "geo_point",
"lat_lon": true
}

}

}
}

$result = $es->search(array(
"query" => array(
"dis_max" => array(
"queries" => array(
0 => array(
"field" => array(
"title" => "palexpo"
)
)
)
)
),
"from" => 0,
"size" => 100000,
"filter" => array(
"geo_distance" => array(
"distance" => "10000mi",
"jos_content.location" => array(
"lat" => "37.77519600",
"lon" => "-122.41920400"
)
)
),
"sort" => array(
//0 => "_score",
0 => array(
"_geo_distance" => array(
"jos_content.location" => array(
"lat" => "37.77519600",
"lon" => "-122.41920400"
),
"order" => "asc",
"unit" => "km"
)
)
)
)
);

Sorry for big code,
Above code gives me nearest distance venue but not palexpo which i actually
search, palexpo comes after 20 25 results.

Please help if you have any suggestion,
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/62b2b233-1818-4e4e-9aee-d42b0683d7c8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

I'm curious, can you show the results (lon, lat values) of the first 25
matches?

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/b89a5d4b-1804-49b4-b558-8743c45a6191%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks for replying Binh,

Yeap first 25 matches having closer distance (lat,lon values) but they are
not relevant matches.

For Ex.
When i search for "palexpo" from San Francisco (37.77519600,-122.41920400)
it gives me,

  1. PLUGZ -- 37.80664300 -122.41628300 -- 2.181 Miles from san francisco
  2. Laemmle's Monica 4-plex -- 34.01522650 -118.49798840 -- 340.395 Miles
  3. Riverside Cinema Six Plex -- 35.16709000 -114.57260000 -- 472.071 Miles
  4. Paramount Tri-Plex -- 43.48080000 -111.99220000 -- 673.978 Miles
    .
    .
    .
    .
  5. Chez les Ploucs 2 -- 44.84471380 -0.57991900 -- 5683.384 Miles
  6. Palexpo -- 46.23106930 6.11826660 -- 5821.611 Miles from san francisco

I know it is sorting by lat,lon values but all 36 results are not relevant.
I hope u will understand Binh.

Thanks,
Vallabh

On Tuesday, February 11, 2014 9:22:34 PM UTC+5:30, Binh Ly wrote:

I'm curious, can you show the results (lon, lat values) of the first 25
matches?

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e38f426f-8b1c-4df0-9307-3b07c7d40322%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Oh I see, sounds like you want to sort by relevance and then have the
distance factored into the relevance score also. You might want to take a
look at the function_score query:

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#_using_function_score

In it, you can combine say a match query with a function where you set the
origin of your geo_point as well as some distance and decay parameters and
that will influence your score based on distance from your origin point.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e011e49f-00b3-46c5-9976-a7029313c00f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.