简体   繁体   English

如何从 elasticsearch 中提取“消息”值? (DSL)

[英]How do I extract the "message" value from elasticsearch? (DSL)

How do I extract the "message" value from elasticsearch?如何从 elasticsearch 中提取“消息”值? (DSL) (DSL)

I tried it.我尝试过这个。 (my code) (我的代码)

-> I want to extract all the "message" values only. -> 我只想提取所有“消息”值。

GET 0503instgram_csv/_search
{
  "query" : {
    "query_string": {
      "default_field": "message",
      "query": ?????????????
    }
  }
}

在此处输入图像描述 -> I want to process the data by saving new field values of all "message" that are printed out. -> 我想通过保存打印出的所有“消息”的新字段值来处理数据。

I'd really appreciate your help.我真的很感谢你的帮助。

@ESCoder This is a picture of the result of the attempt as you said. @ESCoder 这是您所说的尝试结果的图片。 在此处输入图像描述

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 281,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "0503instgram_csv",
        "_type" : "_doc",
        "_id" : "zbKQMXkB98wUkKJOL8dT",
        "_score" : 1.0,
        "_source" : {
          "message" : "\"lovablepoetree"
        }
      },
      {
        "_index" : "0503instgram_csv",
        "_type" : "_doc",
        "_id" : "zrKQMXkB98wUkKJOL8dU",
        "_score" : 1.0,
        "_source" : {
          "message" : """내가 아는 사람 중에 최고 셀럽(@hanstar.kim)과 맥주 마심🍻셀럽과 술이라니....! 성공해따 나자신!!!!!! 그래놓고 사진은 나 혼자 찍어따^.^ 다음번엔 투샷을 찍어보쟈......🥰"""
        }
      },
      {
        "_index" : "0503instgram_csv",
        "_type" : "_doc",
        "_id" : "z7KQMXkB98wUkKJOL8dU",
        "_score" : 1.0,
        "_source" : {
          "message" : """🔥🔥..열정을 응원 합니다. 도대현 드림❤️❤️❤️"""
        }
      },
      {
        "_index" : "0503instgram_csv",
        "_type" : "_doc",
        "_id" : "0LKQMXkB98wUkKJOL8dU",
        "_score" : 1.0,
        "_source" : {
          "message" : "lovablepoetree"
        }
      },
      {
        "_index" : "0503instgram_csv",
        "_type" : "_doc",
        "_id" : "0bKQMXkB98wUkKJOL8dj",
        "_score" : 1.0,
        "_source" : {
          "message" : """좋아요 69개
"""
        }
      },
      {
        "_index" : "0503instgram_csv",
        "_type" : "_doc",
        "_id" : "0rKQMXkB98wUkKJOL8dj",
        "_score" : 1.0,
        "_source" : {
          "message" : """['paulchang1103,Paul Chang (장준성)🇰🇷,passionated_man,도대현,luv_____juju,쥬쥬,koonge01,영이,p.s.j___5959,또둔,panchitoyoon,Ye Suk Yoon,hyeriiing__,혤,sunny.gibbab,써니네식탁(sunny Gib-bab),_wjstn_ry_02,전수교(20),sungwoon_jinsik,윤성운🇰🇷,t_a_k_3014,🎀케이,팔로우']
"""
        }
      },
      {
        "_index" : "0503instgram_csv",
        "_type" : "_doc",
        "_id" : "07KQMXkB98wUkKJOL8dj",
        "_score" : 1.0,
        "_source" : {
          "message" : "passionated_man"
        }
      },
      {
        "_index" : "0503instgram_csv",
        "_type" : "_doc",
        "_id" : "1LKQMXkB98wUkKJOL8dj",
        "_score" : 1.0,
        "_source" : {
          "message" : "1일"
        }
      },
      {
        "_index" : "0503instgram_csv",
        "_type" : "_doc",
        "_id" : "1bKQMXkB98wUkKJOL8dj",
        "_score" : 1.0,
        "_source" : {
          "message" : """🔥🔥..열정을 응원 합니다. 도대현 드림❤️❤️❤️"""
        }
      },
      {
        "_index" : "0503instgram_csv",
        "_type" : "_doc",
        "_id" : "1rKQMXkB98wUkKJOL8dj",
        "_score" : 1.0,
        "_source" : {
          "message" : """1일답글 달기","lovablepoetree"""
        }
      }
    ]
  }
}

You can do source filtering to extract only message field values您可以进行源过滤以仅提取message字段值

GET/_search
{
  "_source": [
    "message"
  ]
}

Update 1:更新1:

You can use the reindex API , to store only the field values of the message field in a different index您可以使用重新索引 API ,仅将message字段的字段值存储在不同的索引中

POST /_reindex
{
  "source": {
    "index": "old-index",
    "_source": ["message"]
  },
  "dest": {
    "index": "new-index"
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python ElasticSearch dsl:如何将一个字段表示为从字符串到整数列表的映射? - Python ElasticSearch dsl: How do I represent a field to be a mapping from a string to a list of ints? 如何使用elasticsearch-dsl-py创建“OR”过滤器? - How do I create an “OR” filter using elasticsearch-dsl-py? 如何使用 Elasticsearch-dsl 在 Django 中进行并行测试? - How can I do parallel tests in Django with Elasticsearch-dsl? 列表中的Python Elasticsearch DSL查询值 - Python Elasticsearch DSL query value from a list 如何使用 elasticsearch-dsl-py 连接两个 ElasticSearch 索引? - How do I join two ElasticSearch indices using elasticsearch-dsl-py? 如何从 kibana 中仅提取“消息”字段值? - How do I extract only "message" field values from kibana? 如何在 Python 中对 Elasticsearch DSL 的结果进行分页 - How to paginate results from Elasticsearch DSL in Python 如何创建Elasticsearch查询DSL以查找具有空数组或同一对象中的值的对象 - How can I create an Elasticsearch Query DSL for finding objects with empty array OR a value in same object 如何使用 Elasticsearch 查询 DSL 来使用 Python 查询 API? - How do I use the Elasticsearch Query DSL to query an API using Python? 如何使用 elasticsearch-dsl-py 创建“或”条件过滤器? - How do I create an “or” Condition filter using elasticsearch-dsl-py?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM