Elasticsearch创建一个索引,该索引包含一个long类型的字段,该字段具有一个初始值

kokeuurv  于 7个月前  发布在  ElasticSearch
关注(0)|答案(1)|浏览(80)

我有以下查询用于创建一个名为highlighttest2的索引。它工作正常,除了spec_label。我试图将其创建为长文本(而不是默认文本),理想情况下,将其初始化为1。下面的操作不正确。感谢正确的语法。谢谢。

POST /highlighttest2/_doc/1
{
  "Id": "1",
  "Reference": "2012-01-01",
  "Title": "Sales Manager",
  "Description": "We are looking for an organized Project Administrator to perform Commercial duties on projects. The Project Administrator is responsible for scheduling meetings, managing office inventory, and tracking expenses. To be successful as a Project Administrator you must be able to multitask. A good Project Administrator has excellent attention to detail.",
  "DescriptionHtml": "<section><p>We are looking for an organized Project Administrator to perform clerical duties on projects.</p> <p>The Project Administrator is responsible for scheduling meetings, managing office inventory, and tracking expenses. To be successful as a Project Administrator you must be able to multitask.</p> <p>A good Project Administrator has excellent attention to detail.</p></section>",
  "Organisation": "US4",
  "myNested":{"spec_label":{"type": "long"}}

字符串
}

n6lpvg4x

n6lpvg4x1#

如果你想创建一个包含特定Map的索引,你首先需要通过提供你想要的mapping来显式地创建它,如下所示:

PUT highlighttest2
{
  "mappings": {
    "properties": {
      "Id": {
        "type": "keyword"
      },
      "Reference": {
        "type": "date"
      },
      ...
      "myNested":{
        "type": "nested",
        "properties": {
           "spec_label":{
              "type": "long"
           }
        }
      }
    }
  }
}

字符串
然后只有您可以索引您的文件与具体的数据

POST /highlighttest2/_doc/1
{
  "Id": "1",
  "Reference": "2012-01-01",
  "Title": "Sales Manager",
  "Description": "We are looking for an organized Project Administrator to perform Commercial duties on projects. The Project Administrator is responsible for scheduling meetings, managing office inventory, and tracking expenses. To be successful as a Project Administrator you must be able to multitask. A good Project Administrator has excellent attention to detail.",
  "DescriptionHtml": "<section><p>We are looking for an organized Project Administrator to perform clerical duties on projects.</p> <p>The Project Administrator is responsible for scheduling meetings, managing office inventory, and tracking expenses. To be successful as a Project Administrator you must be able to multitask.</p> <p>A good Project Administrator has excellent attention to detail.</p></section>",
  "Organisation": "US4",
  "myNested":{
     "spec_label": 12353672
  }
}

相关问题