javascript - How to build the proper mapping/indexing in ElasticSearch with NodeJS -


i have been beating head against day, , cannot seem figure out how work.

i have source document this:

{    "created_at": 1454700182,    "message_id": 160,    "user_id": 1,    "establishment_id": 1,    "geo": {      "coordinates": [-4.8767633,        89.7833547      ],      "type": "point"    },    "message": "venus in west",    "active": true,    "score": 0,    "name": {      "first": "first",      "last": "last"    },    "neighborhood": "townside"  },

i create document in elasticsearch:

{    "message_id": 160,    "message": "venus in west",    "first_name": "first",    "last_name": "last",    "location": {      "lon": -4.8767633,      "lat": 89.7833547    },    "created_at": 1454700182,    "neighborhood": "townside"  }

i've been trying different ways create index.

first:

client.indices.create({        index: 'messages',        type: 'document',        body: {          messages: {            properties: {              message: {                type: 'string',                index: 'not_analyzed'              },              neighborhood: {                type: 'string',                index: 'not_analyzed'              },              first_name: {                type: 'string',                index: 'not_analyzed'              },              last_name: {                type: 'string',                index: 'not_analyzed'              },              created_at: {                type: 'integer',                index: 'not_analyzed'              },              location: {                type: 'geo_point',                lat_lon: true              }            }          }        },      }  );

this allows me fuzzy text searches , greater queries, doesn't recognize geo_point. tried this:

client.indices.create({    index: 'messages',    type: 'document',    "mappings": {      "messages": {        "properties": {          "message": {            "type": "string",            "index": "not_analyzed"          },          "neighborhood": {            "type": "string",            "index": "not_analyzed"          },          "first_name": {            "type": "string",            "index": "not_analyzed"          },          "last_name": {            "type": "string",            "index": "not_analyzed"          },          "created_at": {            "type": "integer",            "index": "not_analyzed"          },          "location": {            "type": "geo_point",            "lat_lon": true,            "index": "not_analyzed"          }        }      }    }  });

this recognize geo_point, none of other things work.

here query i've been using non geo fields:

            query = {                query: {                  filtered: {                    query: {                      multi_match: {                        query: message,                        fields: ['message', 'neighborhood', 'first_name', 'last_name'],                        "fuzziness": "auto",                        "prefix_length": 2                      }                    },                    filter: {                      bool: {                        must: {                          range: {                            "created_at": {                              "gte": min_ts                            }                          }                        }                      }                    }                  }                }              };

i've been turned around on this, trying allow text , geo search on same collection of documents, need @ least set of eyes.

appreciate help!


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -