Problems with Geo Mapping


(tiftif) #1

I am trying to map the geo location data of tweets but I keep getting
errors...

  1. curl -XPUT 'http://localhost:9200/media/'

  2. curl -XPUT 'http://localhost:9200/media/twitter/_mapping' -d '
    {
    "geo" : {
    "properties" : {
    "location" : {
    "type" : "geo_point"
    }
    }
    }
    }
    '

  3. curl -XPUT 'http://localhost:9200/media/twitter/1' -d '
    {
    "geo" : {
    "location" : {
    "lat" : 40.12,
    "lon" : -71.34
    }
    },
    "tags" : ["food", "family"],
    "text" : "my favorite family restaurant"
    }'

  4. curl -XGET 'http://localhost:9200/media/twitter/_search' -d
    '{ "query" : {
    "filtered" : {
    "query" : {
    "field" : { "text" : "restaurant" }
    },
    "filter" : {
    "geo_distance" : {
    "distance" : "200km",
    "geo.location" : {
    "lat" : 40,
    "lon" : -70
    }
    }
    }
    }
    }}'

  5. I get an exception that contains: "failed to find geo_point field
    [geo.location]];"

What am I doing wrong? :frowning:


(tiftif) #2

Okay, I think I figured out what I was doing wrong. I guess I need to
have a single root element that should probably be the same name as
the type itself.

Here's what works:

  1. curl -XDELETE 'http://localhost:9200/media'

  2. curl -XPUT 'http://localhost:9200/media/'

  3. curl -XPUT 'http://localhost:9200/media/twitter/_mapping' -d '
    {
    "twitter" : {
    "properties" : {
    "geo" : {
    "type" : "object",
    "properties" : {
    "location" : {
    "type" : "geo_point"
    }
    }
    }
    }
    }
    }
    '

  4. curl -XPUT 'http://localhost:9200/media/twitter/1' -d '
    {
    "twitter" : {
    "geo" : {
    "location" : {
    "lat" : 40.12,
    "lon" : -71.34
    },
    "tags" : ["food", "family"],
    "text" : "my favorite family restaurant"
    }
    }
    }'

  5. curl -XGET 'http://localhost:9200/media/twitter/_search' -d
    '{ "query" : {
    "filtered" : {
    "query" : {
    "field" : { "text" : "restaurant" }
    },
    "filter" : {
    "geo_distance" : {
    "distance" : "200km",
    "geo.location" : {
    "lat" : 40,
    "lon" : -70
    }
    }
    }
    }
    }}'

On Dec 11, 7:04 pm, tiftif atifsyed...@gmail.com wrote:

I am trying to map the geo location data of tweets but I keep getting
errors...

  1. curl -XPUT 'http://localhost:9200/media/'

  2. curl -XPUT 'http://localhost:9200/media/twitter/_mapping'-d '
    {
    "geo" : {
    "properties" : {
    "location" : {
    "type" : "geo_point"
    }
    }
    }}

'

  1. curl -XPUT 'http://localhost:9200/media/twitter/1'-d '
    {
    "geo" : {
    "location" : {
    "lat" : 40.12,
    "lon" : -71.34
    }
    },
    "tags" : ["food", "family"],
    "text" : "my favorite family restaurant"

}'

  1. curl -XGET 'http://localhost:9200/media/twitter/_search'-d
    '{ "query" : {
    "filtered" : {
    "query" : {
    "field" : { "text" : "restaurant" }
    },
    "filter" : {
    "geo_distance" : {
    "distance" : "200km",
    "geo.location" : {
    "lat" : 40,
    "lon" : -70
    }
    }
    }
    }

}}'

  1. I get an exception that contains: "failed to find geo_point field
    [geo.location]];"

What am I doing wrong? :frowning:


(Shay Banon) #3

Yes, thats the way to do it (sorry for the late response...)

On Mon, Dec 12, 2011 at 2:48 AM, tiftif atifsyedali@gmail.com wrote:

Okay, I think I figured out what I was doing wrong. I guess I need to
have a single root element that should probably be the same name as
the type itself.

Here's what works:

  1. curl -XDELETE 'http://localhost:9200/media'

  2. curl -XPUT 'http://localhost:9200/media/'

  3. curl -XPUT 'http://localhost:9200/media/twitter/_mapping' -d '
    {
    "twitter" : {
    "properties" : {
    "geo" : {
    "type" : "object",
    "properties" : {
    "location" : {
    "type" : "geo_point"
    }
    }
    }
    }
    }
    }
    '

  4. curl -XPUT 'http://localhost:9200/media/twitter/1' -d '
    {
    "twitter" : {
    "geo" : {
    "location" : {
    "lat" : 40.12,
    "lon" : -71.34
    },
    "tags" : ["food", "family"],
    "text" : "my favorite family restaurant"
    }
    }
    }'

  5. curl -XGET 'http://localhost:9200/media/twitter/_search' -d
    '{ "query" : {
    "filtered" : {
    "query" : {
    "field" : { "text" : "restaurant" }
    },
    "filter" : {
    "geo_distance" : {
    "distance" : "200km",
    "geo.location" : {
    "lat" : 40,
    "lon" : -70
    }
    }
    }
    }
    }}'

On Dec 11, 7:04 pm, tiftif atifsyed...@gmail.com wrote:

I am trying to map the geo location data of tweets but I keep getting
errors...

  1. curl -XPUT 'http://localhost:9200/media/'

  2. curl -XPUT 'http://localhost:9200/media/twitter/_mapping'-d '
    {
    "geo" : {
    "properties" : {
    "location" : {
    "type" : "geo_point"
    }
    }
    }}

'

  1. curl -XPUT 'http://localhost:9200/media/twitter/1'-d '
    {
    "geo" : {
    "location" : {
    "lat" : 40.12,
    "lon" : -71.34
    }
    },
    "tags" : ["food", "family"],
    "text" : "my favorite family restaurant"

}'

  1. curl -XGET 'http://localhost:9200/media/twitter/_search'-d
    '{ "query" : {
    "filtered" : {
    "query" : {
    "field" : { "text" : "restaurant" }
    },
    "filter" : {
    "geo_distance" : {
    "distance" : "200km",
    "geo.location" : {
    "lat" : 40,
    "lon" : -70
    }
    }
    }
    }

}}'

  1. I get an exception that contains: "failed to find geo_point field
    [geo.location]];"

What am I doing wrong? :frowning:


(system) #4