json - 在负载中指定 elasticsearch 索引

标签 json elasticsearch indexing

我的查询

我正在写一个 Elasticsearch查询并在 URL 中指定请求的 index 并在外部 JSON 文件中指定查询:

curl

curl -s \
     -u $user:$pass \
     https://example.com:9243/index_name/search 
     -d @query.json

查询.json

{
  "size": 5,
  "from": 0,
  "sort": [
    {
      "@timestamp": {
        "order": "desc",
        "unmapped_type": "boolean"
      }
    }
  ],
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "source:*.log",
            "analyze_wildcard": true
          }
        }
      ]
    }
  },
  "_source": {
      "include": ["message", "@timestamp"],
      "exclude": "_*"
  }
}

我的问题

我想在查询文件中声明索引名称,而不是 URL。

我尝试了什么

我的问题

中指定索引的正确方法是什么

最佳答案

indices query ,在那里你会看到你可以在 json 查询中设置索引。

如果您有任何问题,请告诉我。

关于json - 在负载中指定 elasticsearch 索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46632069/

相关文章:

mysql - Golang JSON 编码将表情符号转换为问号

php - 使用 Swift 在 POST 请求中将正确转义的 JSON 提交给 PHP

elasticsearch - 无法锁定 JVM 内存 : error=12, 原因=无法分配内存 - Elasticsearch 6.2.4

c++ - std::vector size()-1 是否总是给出最后一个元素的索引?

json - react 获取 : Getting json result but showing network error

PHP将嵌套的json插入到mySQl中

java - 在 Elasticsearch 中刷新失败后碎片未分配

ElasticSearch Couchbase 复制问题

html - CSS 无法识别

mysql - 如何修复 MySql : index column size too large (Laravel migrate)