Skip to content

Elastic search index setup

Nithin Krishna edited this page Aug 10, 2016 · 2 revisions

###Creating an index

curl -X POST "http://ES-INDEX-URL/INDEX-NAME"

###Genrating Mapping

curl -X POST -d '
{
  "docs": {
    "properties": {
      "dates": {
        "type": "nested",
        "properties": {
          "count": {
            "type": "long"
          },
          "name": {
            "type": "long"
          }
        }
      },
      "entities": {
        "type": "nested",
        "properties": {
          "count": {
            "type": "long"
          },
          "name": {
            "type": "string",
            "fields": {
              "raw": {
                "type": "string",
                "index": "not_analyzed",
                "null_value": "NULL"
              }
            }
          }
        }
      },
      "geo": {
        "type": "nested",
        "properties": {
          "admin1Code": {
            "type": "string",
            "fields": {
              "raw": {
                "type": "string",
                "index": "not_analyzed",
                "null_value": "NULL"
              }
            }
          },
          "admin2Code": {
            "type": "string",
            "fields": {
              "raw": {
                "type": "string",
                "index": "not_analyzed",
                "null_value": "NULL"
              }
            }
          },
          "countryCode": {
            "type": "string",
            "fields": {
              "raw": {
                "type": "string",
                "index": "not_analyzed",
                "null_value": "NULL"
              }
            }
          },
          "location": {
            "type": "geo_point",
            "lat_lon": true,
            "geohash": true
          },
          "name": {
            "type": "string",
            "fields": {
              "raw": {
                "type": "string",
                "index": "not_analyzed",
                "null_value": "NULL"
              }
            }
          }
        }
      },
      "id": {
        "type": "string"
      },
      "locations": {
        "type": "geo_point",
        "lat_lon": true,
        "geohash": true
      },
      "mime-type": {
        "type": "string",
        "fields": {
          "raw": {
            "type": "string",
            "index": "not_analyzed",
            "null_value": "NULL"
          }
        }
      },
      "places": {
        "type": "nested",
        "properties": {
          "count": {
            "type": "long"
          },
          "name": {
            "type": "string",
            "fields": {
              "raw": {
                "type": "string",
                "index": "not_analyzed",
                "null_value": "NULL"
              }
            }
          }
        }
      },
      "quantities": {
        "type": "nested",
        "properties": {
          "normalizedQuantity": {
            "type": "long"
          },
          "normalizedUnit": {
            "type": "nested",
            "properties": {
              "name": {
                "type": "string",
                "fields": {
                  "raw": {
                    "type": "string",
                    "index": "not_analyzed",
                    "null_value": "NULL"
                  }
                }
              },
              "normalizedQuantity": {
                "type": "long"
              },
              "parsedValue": {
                "type": "long"
              },
              "system": {
                "type": "string",
                "index": "no",
                "fields": {
                  "name": {
                    "type": "string"
                  },
                  "raw": {
                    "type": "string",
                    "index": "not_analyzed",
                    "null_value": "NULL"
                  }
                }
              },
              "type": {
                "type": "string",
                "index": "no",
                "fields": {
                  "name": {
                    "type": "string"
                  },
                  "raw": {
                    "type": "string",
                    "index": "not_analyzed",
                    "null_value": "NULL"
                  }
                }
              }
            }
          },
          "offsetEnd": {
            "type": "long"
          },
          "offsetStart": {
            "type": "long"
          },
          "parsedValue": {
            "type": "long"
          },
          "rawUnit": {
            "type": "nested",
            "properties": {
              "name": {
                "type": "string",
                "fields": {
                  "raw": {
                    "type": "string",
                    "index": "not_analyzed",
                    "null_value": "NULL"
                  }
                }
              },
              "normalizedQuantity": {
                "type": "long"
              },
              "offsetEnd": {
                "type": "long"
              },
              "offsetStart": {
                "type": "long"
              },
              "parsedValue": {
                "type": "long"
              },
              "system": {
                "type": "string",
                "index": "no",
                "fields": {
                  "name": {
                    "type": "string"
                  },
                  "raw": {
                    "type": "string",
                    "index": "not_analyzed",
                    "null_value": "NULL"
                  }
                }
              },
              "type": {
                "type": "string",
                "index": "no",
                "fields": {
                  "name": {
                    "type": "string"
                  },
                  "raw": {
                    "type": "string",
                    "index": "not_analyzed",
                    "null_value": "NULL"
                  }
                }
              }
            }
          },
          "rawValue": {
            "type": "string"
          },
          "type": {
            "type": "string"
          }
        }
      }
    }
  }
}' "http://ES-INDEX-URL/INDEX-NAME/docs/_mapping"
Clone this wiki locally