elastic查询在kibana和nest库中给出不同的结果

rjee0c15  于 2021-06-13  发布在  ElasticSearch
关注(0)|答案(1)|浏览(344)

我正在使用.net库嵌套,它生成以下查询:

{
  "query": {
    "function_score": {
      "boost_mode": "sum",
      "functions": [
        {
          "filter": {
            "term": {
              "technicalSkills.id": {
                "value": "9a4fb532e3544d5ab39ce610"
              }
            }
          },
          "script_score": {
            "script": {
              "source": "(doc['technicalSkills.yearsOfExperience'].value/params.minYears)",
              "params": {
                "minYears": 2
              }
            }
          }
        }
      ]
    }
  }
}

在我的代码中返回正确的结果。我得到一堆结果,当我在调试器中检查它们时,它们看起来是这样的:

{
"_index": "resumes",
"_type": "_doc",
"_id": "73c47133-8656-45e7-9499-14f52df07b71",
"_score": 2.0,
"_source": {...}
}

哪里 _source 是我想要的东西。但是,现在我想手动调整查询以获得所需的结果。为此,我将查询复制粘贴到kibana的devtools控制台中,但得到的结果完全不同:

"took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 6,
    "successful" : 6,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 34,
      "relation" : "eq"
    },
    "max_score" : 2.0,
    "hits" : [
      {
        "_index" : ".kibana-event-log-7.9.2-000001",
        "_type" : "_doc",
        "_id" : "n5IkGHYBJCT4zPkeFVUB",
        "_score" : 2.0,
        "_source" : {
          "event" : {
            "provider" : "eventLog",
            "action" : "starting"
          },
          "message" : "eventLog starting",
          "@timestamp" : "2020-11-30T07:53:05.349Z",
          "ecs" : {
            "version" : "1.5.0"
          },
          "kibana" : {
            "server_uuid" : "b2ed4371-51da-4831-8807-7907eb012b44"
          }
        }
      },
      {
        "_index" : ".kibana-event-log-7.9.2-000001",
        "_type" : "_doc",
        "_id" : "hmc2GHYBvJoeceksDNr9",
        "_score" : 2.0,
        "_source" : {
          "event" : {
            "provider" : "eventLog",
            "action" : "starting"
          },
          "message" : "eventLog starting",
          "@timestamp" : "2020-11-30T08:12:43.823Z",
          "ecs" : {
            "version" : "1.5.0"
          },
          "kibana" : {
            "server_uuid" : "c060c8bc-acc6-4ad0-96f8-54cc10f91e34"
          }
        }
      },

我只是得到了一吨 .kibana-event-log 结果和几个巨大的数据URL:

"assets" : {
                  "asset-c9ab1060-1cb4-49c6-9225-7e729c91c37c" : {
                    "id" : "asset-c9ab1060-1cb4-49c6-9225-7e729c91c37c",
                    "@created" : "2019-04-10T13:18:28.377Z",
                    "type" : "dataurl",
                    "value" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA  etc etc
                     HUGE block of text

我在结果中也看到了某种html:

| demodata
| markdown 
  "### Subsection with live data elements

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat." 
  font={font family="'Open Sans', Helvetica, Arial, sans-serif" size=14 align="left" color="#1785b0" weight="normal" underline=false italic=false}
| render"""
                    },
                    {
                      "id" : "element-827e63a5-2f89-4eb1-95e1-9ac492bce7d9",
                      "position" : {
                        "left" : 25,
                        "top" : 747,
                        "width" : 563,
                        "height" : 29,
                        "angle" : 0,
                        "parent" : null
                      },
                      "expression" : "filters\n| demodata\n| markdown \"- 6\n- yoursite.com\n- © 2019 Company Name Here. All Rights Reserved.     \"\n| render \n  css=\".canvasMarkdown ul {\npadding-left: 0;\n}\n\n.canvasMarkdown li {\nfont-size: 12px;\ncolor: #A4A4A4;\nlist-style: none;\ndisplay: inline-block;\nmargin-right: 1em;\npadding-right: 1em;\nborder-right: 1px solid #A4A4A4;\n}\n\n.canvasMarkdown li:last-child {\nborder-right: none;\npadding-right: 0;\nmargin-right: 0;\""
                    },
                    {

为什么kibana给我展示了不同的结果?如何让它显示与代码中相同的结果?

u2nhd7ah

u2nhd7ah1#

你得跑了 GET resumes/_search 而不仅仅是 GET _search 它查询所有可用的索引。

相关问题