Trying to query geo_distance


(Warner Onstine) #1

I'm having some issues querying geo_distance in my ES index. Here's my mapping:
{
"Event": {
"properties" : {
"docType": {"type": "string", "store":"yes"},
"description" : {"type" : "string", "store" : "yes"},
"title" : {"type" : "string", "store" : "yes"},
"location" : { "type" : "geo_point", "lat_lon":
"true","store":"yes" },
"startTime" : {"type": "date", "store": "yes"},
"tags" : {"type" : "string", "index_name" : "tag"}
}
}
}

I have documents that look like this:

{
"_index" : "syncrswim",
"_type" : "syncrswim",
"_id" : "3e9e9d1f82385af7e01146f8a4063d42",
"_score" : 0.13977994, "_source" : {"docType":"Event",
"location":{"lon":-110.944703,"lat":32.254652},
"lastUpdated":"2012-06-08T04:12:51",
"provider":"eventbrite",
"externalId":"2487867278",
"stopTime":"2016-08-19T23:00:00",
"_rev":"2-4d5ec9d8fe68689d781493e847600baa",
"startTime":"2015-04-26T03:00:00",
"externalUpdatedDate":"2012-06-08T04:12:51",
"title":"Tucson Young Professionals Membership",
"_id":"3e9e9d1f82385af7e01146f8a4063d42",
"description":"Tucson Young Professionals ...",
"venueId":"3e9e9d1f82385af7e01146f8a40642a4"}

When I do a query like this it works fine:
"query": {
"filtered" : {
"query" : {
"query_string" : {
"query" : "Aesop",
"fields" : [ "title", "description" ]
}
},
"filter" : {
"term" : {
"docType" : "event"
}
}
}
}

I have tried this kind of query:
{
"filtered" : {
"query" : {
"query_string" : {
"query" : "Aesop",
"fields" : [ "title", "description" ]
}
},
"filter" : {
"and" : {
"filters" : [ {
"term" : {
"docType" : "event"
}
}, {
"geo_distance" : {
"location" : {
"lat": 32.2217429,
"long" : -110.926479
},
"distance" : "25.0mi"
}
} ]
}
}
}
}

but that returns zero results. I've tried a different query:
{"query" : {"filtered" : {"query" : {"query_string" : {"query" :
"annual","fields" : [ "title", "description" ]}},"filter" : {"and" :
{"filters" : [ {"term" : {"docType" : "event"}}, {"geo_distance" :
{"Event.location" : {"lat": 32.2217429,"lon" : -110.926479},"distance"
: "50mi"}} ]}}}}}

Which also returns zero results.

Here is the full mapping as returned through _mapping.
{ "syncrswim" : { "syncrswim" : {
"properties" : {
"_rev" : {
"type" : "string"
},
"address1" : {
"type" : "string"
},
"city" : {
"type" : "string"
},
"description" : {
"type" : "string"
},
"docType" : {
"type" : "string"
},
"externalId" : {
"type" : "string"
},
"externalUpdatedDate" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"lastUpdated" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"links" : {
"dynamic" : "true",
"properties" : {
"image" : {
"type" : "string"
},
"main" : {
"type" : "string"
}
}
},
"location" : {
"dynamic" : "true",
"properties" : {
"lat" : {
"type" : "double"
},
"lon" : {
"type" : "double"
}
}
},
"name" : {
"type" : "string"
},
"postalCode" : {
"type" : "string"
},
"provider" : {
"type" : "string"
},
"startTime" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"state" : {
"type" : "string"
},
"stopTime" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"tags" : {
"type" : "string"
},
"title" : {
"type" : "string"
},
"venueId" : {
"type" : "string"
}
}
},
"Place" : {
"properties" : {
"address1" : {
"type" : "string",
"store" : "yes"
},
"city" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"name" : {
"type" : "string",
"store" : "yes"
},
"state" : {
"type" : "string",
"store" : "yes"
}
}
},
"Event" : {
"properties" : {
"description" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"startTime" : {
"type" : "date",
"store" : "yes",
"format" : "dateOptionalTime"
},
"tags" : {
"type" : "string",
"index_name" : "tag"
},
"title" : {
"type" : "string",
"store" : "yes"
}
}
}
}
}

Any thoughts?

-warner


(Clinton Gormley) #2

Hiya

Your 'location' field should of type "geo_point", not "object" (which is
what it is now):

    "location" : {
      "dynamic" : "true",
      "properties" : {
        "lat" : {
          "type" : "double"
        },
        "lon" : {
          "type" : "double"
        }
      }
    },

See
http://www.elasticsearch.org/guide/reference/mapping/geo-point-type.html

clint


(Warner Onstine) #3

Not sure how that got in there, but when I push it in to ES, it is a geo_point:

"Event" : {
"properties" : {
"description" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
...

That was one of the things I wasn't sure on. The mapping data is in
the db twice somehow. Not sure if ES does something automatic? But I
specify the "Event" and "Place" mappings.

-warner

On Mon, Jul 23, 2012 at 2:27 AM, Clinton Gormley clint@traveljury.com wrote:

Hiya

Your 'location' field should of type "geo_point", not "object" (which is
what it is now):

    "location" : {
      "dynamic" : "true",
      "properties" : {
        "lat" : {
          "type" : "double"
        },
        "lon" : {
          "type" : "double"
        }
      }
    },

See
http://www.elasticsearch.org/guide/reference/mapping/geo-point-type.html

clint


(Warner Onstine) #4

Ok, I wiped out the existing mapping and completely redid it, this
time adding in "dynamic":false on the location(s) but I'm still not
getting anything back. Here's the new full _mapping returned.
{
"syncrswim" : {
"Place" : {
"properties" : {
"address1" : {
"type" : "string",
"store" : "yes"
},
"city" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"name" : {
"type" : "string",
"store" : "yes"
},
"state" : {
"type" : "string",
"store" : "yes"
}
}
},
"syncrswim" : {
"properties" : {
"address1" : {
"type" : "string",
"store" : "yes"
},
"address2" : {
"type" : "string",
"store" : "yes"
},
"city" : {
"type" : "string",
"store" : "yes"
},
"description" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"name" : {
"type" : "string",
"store" : "yes"
},
"startTime" : {
"type" : "date",
"store" : "yes",
"format" : "dateOptionalTime"
},
"state" : {
"type" : "string",
"store" : "yes"
},
"tags" : {
"type" : "string",
"index_name" : "tag"
},
"title" : {
"type" : "string",
"store" : "yes"
}
}
},
"Event" : {
"properties" : {
"description" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"startTime" : {
"type" : "date",
"store" : "yes",
"format" : "dateOptionalTime"
},
"tags" : {
"type" : "string",
"index_name" : "tag"
},
"title" : {
"type" : "string",
"store" : "yes"
}
}
}
}
}

Do I also have to add back in the properties for lat/lon under the
location? The examples don't talk about that so I'm not sure if that's
necessary when I've specified lat_lon as true.

Thanks!

-warner

On Mon, Jul 23, 2012 at 6:30 AM, Warner Onstine warnero@gmail.com wrote:

Not sure how that got in there, but when I push it in to ES, it is a geo_point:

"Event" : {
"properties" : {
"description" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
...

That was one of the things I wasn't sure on. The mapping data is in
the db twice somehow. Not sure if ES does something automatic? But I
specify the "Event" and "Place" mappings.

-warner

On Mon, Jul 23, 2012 at 2:27 AM, Clinton Gormley clint@traveljury.com wrote:

Hiya

Your 'location' field should of type "geo_point", not "object" (which is
what it is now):

    "location" : {
      "dynamic" : "true",
      "properties" : {
        "lat" : {
          "type" : "double"
        },
        "lon" : {
          "type" : "double"
        }
      }
    },

See
http://www.elasticsearch.org/guide/reference/mapping/geo-point-type.html

clint


(Warner Onstine) #5

Think I finally got it to work! I ingested a whole batch of new docs
which got the index working again and now this query works

curl -XGET 'http://localhost:9200/syncrswim/_search?pretty=tru' -d
'{"query" : {"filtered" : {"query" : {"query_string" : {"query" :
"annual","fields" : [ "title", "description" ]}},"filter" : {"and" :
{"filters" : [ {"term" : {"docType" : "event"}}, {"geo_distance" :
{"location" : {"lat": 32.2217429,"lon" : -110.926479},"distance" :
"50mi"}} ]}}}}}'

Thank you :).

-warner

On Mon, Jul 23, 2012 at 7:07 AM, Warner Onstine warnero@gmail.com wrote:

Ok, I wiped out the existing mapping and completely redid it, this
time adding in "dynamic":false on the location(s) but I'm still not
getting anything back. Here's the new full _mapping returned.
{
"syncrswim" : {
"Place" : {
"properties" : {
"address1" : {
"type" : "string",
"store" : "yes"
},
"city" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"name" : {
"type" : "string",
"store" : "yes"
},
"state" : {
"type" : "string",
"store" : "yes"
}
}
},
"syncrswim" : {
"properties" : {
"address1" : {
"type" : "string",
"store" : "yes"
},
"address2" : {
"type" : "string",
"store" : "yes"
},
"city" : {
"type" : "string",
"store" : "yes"
},
"description" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"name" : {
"type" : "string",
"store" : "yes"
},
"startTime" : {
"type" : "date",
"store" : "yes",
"format" : "dateOptionalTime"
},
"state" : {
"type" : "string",
"store" : "yes"
},
"tags" : {
"type" : "string",
"index_name" : "tag"
},
"title" : {
"type" : "string",
"store" : "yes"
}
}
},
"Event" : {
"properties" : {
"description" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"startTime" : {
"type" : "date",
"store" : "yes",
"format" : "dateOptionalTime"
},
"tags" : {
"type" : "string",
"index_name" : "tag"
},
"title" : {
"type" : "string",
"store" : "yes"
}
}
}
}
}

Do I also have to add back in the properties for lat/lon under the
location? The examples don't talk about that so I'm not sure if that's
necessary when I've specified lat_lon as true.

Thanks!

-warner

On Mon, Jul 23, 2012 at 6:30 AM, Warner Onstine warnero@gmail.com wrote:

Not sure how that got in there, but when I push it in to ES, it is a geo_point:

"Event" : {
"properties" : {
"description" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
...

That was one of the things I wasn't sure on. The mapping data is in
the db twice somehow. Not sure if ES does something automatic? But I
specify the "Event" and "Place" mappings.

-warner

On Mon, Jul 23, 2012 at 2:27 AM, Clinton Gormley clint@traveljury.com wrote:

Hiya

Your 'location' field should of type "geo_point", not "object" (which is
what it is now):

    "location" : {
      "dynamic" : "true",
      "properties" : {
        "lat" : {
          "type" : "double"
        },
        "lon" : {
          "type" : "double"
        }
      }
    },

See
http://www.elasticsearch.org/guide/reference/mapping/geo-point-type.html

clint


(Warner Onstine) #6

Hi all, after getting this working again I ingested more docs into my
database and it stopped working. When I look up my mapping it created
this section all over again, even though I specified location field to
be not-dynamic.

{
"syncrswim" : {
"syncrswim" : {
"properties" : {
"_rev" : {
"type" : "string"
},
"address1" : {
"type" : "string"
},
"city" : {
"type" : "string"
},
"description" : {
"type" : "string"
},
"docType" : {
"type" : "string"
},
"externalId" : {
"type" : "string"
},
"externalUpdatedDate" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"lastUpdated" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"links" : {
"dynamic" : "true",
"properties" : {
"main" : {
"type" : "string"
}
}
},
"location" : {
"dynamic" : "true",
"properties" : {
"lat" : {
"type" : "double"
},
"lon" : {
"type" : "double"
}
}
},
"name" : {
"type" : "string"
},
"postalCode" : {
"type" : "string"
},
"provider" : {
"type" : "string"
},
"startTime" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"state" : {
"type" : "string"
},
"title" : {
"type" : "string"
},
"venueId" : {
"type" : "string"
}
}
},
"Place" : {
"properties" : {
"address1" : {
"type" : "string",
"store" : "yes"
},
"address2" : {
"type" : "string",
"store" : "yes"
},
"city" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"name" : {
"type" : "string",
"store" : "yes"
},
"state" : {
"type" : "string",
"store" : "yes"
}
}
},
"Event" : {
"properties" : {
"description" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"startTime" : {
"type" : "date",
"store" : "yes",
"format" : "dateOptionalTime"
},
"tags" : {
"type" : "string",
"index_name" : "tag"
},
"title" : {
"type" : "string",
"store" : "yes"
}
}
}
}
}

Now, when I'm pushing my mappings I'm only pushing Event and Place,
the rest is all done through the dynamic mapping. Now, I don't think I
want to disable dynamic mapping, but I certainly don't want it
dynamically create the location as an object.

How do I specify an overall mapping for my documents being ingested so
that it doesn't do this? My index is syncrswim and my base type is
syncrswim (when I created my index), under that I created two mappings
for Event and Place, so do I need create a mapping for syncrswim and
place location in there as well?

Thanks in advance!

-warner

On Mon, Jul 23, 2012 at 7:31 AM, Warner Onstine warnero@gmail.com wrote:

Think I finally got it to work! I ingested a whole batch of new docs
which got the index working again and now this query works

curl -XGET 'http://localhost:9200/syncrswim/_search?pretty=tru' -d
'{"query" : {"filtered" : {"query" : {"query_string" : {"query" :
"annual","fields" : [ "title", "description" ]}},"filter" : {"and" :
{"filters" : [ {"term" : {"docType" : "event"}}, {"geo_distance" :
{"location" : {"lat": 32.2217429,"lon" : -110.926479},"distance" :
"50mi"}} ]}}}}}'

Thank you :).

-warner

On Mon, Jul 23, 2012 at 7:07 AM, Warner Onstine warnero@gmail.com wrote:

Ok, I wiped out the existing mapping and completely redid it, this
time adding in "dynamic":false on the location(s) but I'm still not
getting anything back. Here's the new full _mapping returned.
{
"syncrswim" : {
"Place" : {
"properties" : {
"address1" : {
"type" : "string",
"store" : "yes"
},
"city" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"name" : {
"type" : "string",
"store" : "yes"
},
"state" : {
"type" : "string",
"store" : "yes"
}
}
},
"syncrswim" : {
"properties" : {
"address1" : {
"type" : "string",
"store" : "yes"
},
"address2" : {
"type" : "string",
"store" : "yes"
},
"city" : {
"type" : "string",
"store" : "yes"
},
"description" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"name" : {
"type" : "string",
"store" : "yes"
},
"startTime" : {
"type" : "date",
"store" : "yes",
"format" : "dateOptionalTime"
},
"state" : {
"type" : "string",
"store" : "yes"
},
"tags" : {
"type" : "string",
"index_name" : "tag"
},
"title" : {
"type" : "string",
"store" : "yes"
}
}
},
"Event" : {
"properties" : {
"description" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"startTime" : {
"type" : "date",
"store" : "yes",
"format" : "dateOptionalTime"
},
"tags" : {
"type" : "string",
"index_name" : "tag"
},
"title" : {
"type" : "string",
"store" : "yes"
}
}
}
}
}

Do I also have to add back in the properties for lat/lon under the
location? The examples don't talk about that so I'm not sure if that's
necessary when I've specified lat_lon as true.

Thanks!

-warner

On Mon, Jul 23, 2012 at 6:30 AM, Warner Onstine warnero@gmail.com wrote:

Not sure how that got in there, but when I push it in to ES, it is a geo_point:

"Event" : {
"properties" : {
"description" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
...

That was one of the things I wasn't sure on. The mapping data is in
the db twice somehow. Not sure if ES does something automatic? But I
specify the "Event" and "Place" mappings.

-warner

On Mon, Jul 23, 2012 at 2:27 AM, Clinton Gormley clint@traveljury.com wrote:

Hiya

Your 'location' field should of type "geo_point", not "object" (which is
what it is now):

    "location" : {
      "dynamic" : "true",
      "properties" : {
        "lat" : {
          "type" : "double"
        },
        "lon" : {
          "type" : "double"
        }
      }
    },

See
http://www.elasticsearch.org/guide/reference/mapping/geo-point-type.html

clint

--


(Warner Onstine) #7

I think I finally figured it out by adding in a type for syncrswim
(and conversely understanding mappings a bit better).

-warner

On Wed, Aug 15, 2012 at 7:55 PM, Warner Onstine warnero@gmail.com wrote:

Hi all, after getting this working again I ingested more docs into my
database and it stopped working. When I look up my mapping it created
this section all over again, even though I specified location field to
be not-dynamic.

{
"syncrswim" : {
"syncrswim" : {
"properties" : {
"_rev" : {
"type" : "string"
},
"address1" : {
"type" : "string"
},
"city" : {
"type" : "string"
},
"description" : {
"type" : "string"
},
"docType" : {
"type" : "string"
},
"externalId" : {
"type" : "string"
},
"externalUpdatedDate" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"lastUpdated" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"links" : {
"dynamic" : "true",
"properties" : {
"main" : {
"type" : "string"
}
}
},
"location" : {
"dynamic" : "true",
"properties" : {
"lat" : {
"type" : "double"
},
"lon" : {
"type" : "double"
}
}
},
"name" : {
"type" : "string"
},
"postalCode" : {
"type" : "string"
},
"provider" : {
"type" : "string"
},
"startTime" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"state" : {
"type" : "string"
},
"title" : {
"type" : "string"
},
"venueId" : {
"type" : "string"
}
}
},
"Place" : {
"properties" : {
"address1" : {
"type" : "string",
"store" : "yes"
},
"address2" : {
"type" : "string",
"store" : "yes"
},
"city" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"name" : {
"type" : "string",
"store" : "yes"
},
"state" : {
"type" : "string",
"store" : "yes"
}
}
},
"Event" : {
"properties" : {
"description" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"startTime" : {
"type" : "date",
"store" : "yes",
"format" : "dateOptionalTime"
},
"tags" : {
"type" : "string",
"index_name" : "tag"
},
"title" : {
"type" : "string",
"store" : "yes"
}
}
}
}
}

Now, when I'm pushing my mappings I'm only pushing Event and Place,
the rest is all done through the dynamic mapping. Now, I don't think I
want to disable dynamic mapping, but I certainly don't want it
dynamically create the location as an object.

How do I specify an overall mapping for my documents being ingested so
that it doesn't do this? My index is syncrswim and my base type is
syncrswim (when I created my index), under that I created two mappings
for Event and Place, so do I need create a mapping for syncrswim and
place location in there as well?

Thanks in advance!

-warner

On Mon, Jul 23, 2012 at 7:31 AM, Warner Onstine warnero@gmail.com wrote:

Think I finally got it to work! I ingested a whole batch of new docs
which got the index working again and now this query works

curl -XGET 'http://localhost:9200/syncrswim/_search?pretty=tru' -d
'{"query" : {"filtered" : {"query" : {"query_string" : {"query" :
"annual","fields" : [ "title", "description" ]}},"filter" : {"and" :
{"filters" : [ {"term" : {"docType" : "event"}}, {"geo_distance" :
{"location" : {"lat": 32.2217429,"lon" : -110.926479},"distance" :
"50mi"}} ]}}}}}'

Thank you :).

-warner

On Mon, Jul 23, 2012 at 7:07 AM, Warner Onstine warnero@gmail.com wrote:

Ok, I wiped out the existing mapping and completely redid it, this
time adding in "dynamic":false on the location(s) but I'm still not
getting anything back. Here's the new full _mapping returned.
{
"syncrswim" : {
"Place" : {
"properties" : {
"address1" : {
"type" : "string",
"store" : "yes"
},
"city" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"name" : {
"type" : "string",
"store" : "yes"
},
"state" : {
"type" : "string",
"store" : "yes"
}
}
},
"syncrswim" : {
"properties" : {
"address1" : {
"type" : "string",
"store" : "yes"
},
"address2" : {
"type" : "string",
"store" : "yes"
},
"city" : {
"type" : "string",
"store" : "yes"
},
"description" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"name" : {
"type" : "string",
"store" : "yes"
},
"startTime" : {
"type" : "date",
"store" : "yes",
"format" : "dateOptionalTime"
},
"state" : {
"type" : "string",
"store" : "yes"
},
"tags" : {
"type" : "string",
"index_name" : "tag"
},
"title" : {
"type" : "string",
"store" : "yes"
}
}
},
"Event" : {
"properties" : {
"description" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"startTime" : {
"type" : "date",
"store" : "yes",
"format" : "dateOptionalTime"
},
"tags" : {
"type" : "string",
"index_name" : "tag"
},
"title" : {
"type" : "string",
"store" : "yes"
}
}
}
}
}

Do I also have to add back in the properties for lat/lon under the
location? The examples don't talk about that so I'm not sure if that's
necessary when I've specified lat_lon as true.

Thanks!

-warner

On Mon, Jul 23, 2012 at 6:30 AM, Warner Onstine warnero@gmail.com wrote:

Not sure how that got in there, but when I push it in to ES, it is a geo_point:

"Event" : {
"properties" : {
"description" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
...

That was one of the things I wasn't sure on. The mapping data is in
the db twice somehow. Not sure if ES does something automatic? But I
specify the "Event" and "Place" mappings.

-warner

On Mon, Jul 23, 2012 at 2:27 AM, Clinton Gormley clint@traveljury.com wrote:

Hiya

Your 'location' field should of type "geo_point", not "object" (which is
what it is now):

    "location" : {
      "dynamic" : "true",
      "properties" : {
        "lat" : {
          "type" : "double"
        },
        "lon" : {
          "type" : "double"
        }
      }
    },

See
http://www.elasticsearch.org/guide/reference/mapping/geo-point-type.html

clint

--


(system) #8