yesman
yesman

Reputation: 7829

Elastic query gives different results in Kibana and Nest library

I'm using the .Net library Nest, which generates this query:

{
  "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
              }
            }
          }
        }
      ]
    }
  }
}

Which returns the correct results inside my code. I get a bunch of results, and when I inspect them in the debugger they look like this:

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

Where _source is the object I want. However, now I want to manually adjust the query to get the results I want. To do this, I copy paste the query into Kibana's devtools console, but I'm getting a completely different result:

  "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"
          }
        }
      },

I'm just getting a ton of .kibana-event-log results, and a couple of huge dataurls:

   "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

I'm also seeing some kind of HTML inside of the results:

| 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;\""
                    },
                    {

Why does Kibana show me different results? How do I get it to show me the same results as in my code?

Upvotes: 0

Views: 215

Answers (1)

Joe - Check out my books
Joe - Check out my books

Reputation: 16915

You've got to run GET resumes/_search instead of just GET _search which queries all available indices.

Upvotes: 1

Related Questions