Why 404 occured when use es.search() in kibana6.x?


(Kwan) #1

here is my code
`

es.search({
      index: kbnIndex,
      type: "index-pattern",
      body: {
        query: {
          "ids":
          {
            "type" : "index-pattern",
            "values" : [$scope.vis.indexPattern.id]
          }
        }
      }
  }, function (error, response) {
 } );

`
when I check in chrome dev tool network,
It says http://localhost:5601/olv/elasticsearch/.kibana/index-pattern/_search 404 not found
But everything in kibana5.x works fine.
Does anyone know how to let es.search() work in kibana6.x? thanks very much


(Jon Budzenski) #2

Starting in 6.x kibana documents are all a single type, does

es.search({
      index: kbnIndex,
      type: "doc", //here
      body: {
        query: {
          "ids":
          {
            "type" : "index-pattern",
            "values" : [$scope.vis.indexPattern.id]
          }
        }
      }
  }, function (error, response) {
 } );

work for you?


(Kwan) #4

Thanks for replying. I tried but still got 404 on 6.x

POST 
http://localhost:5601/ztc/elasticsearch/.kibana/doc/_search
{"query":{"ids":{"type":"index-pattern","values":["3851cd60-0450-11e8-8f86-9312c81e614d"]}}}

And I want result like this

{
	"took": 0,
	"timed_out": false,
	"_shards": {
		"total": 1,
		"successful": 1,
		"failed": 0
	},
	"hits": {
		"total": 1,
		"max_score": 1.0,
		"hits": [{
			"_index": ".kibana",
			"_type": "index-pattern",
			"_id": "demo-image",
			"_score": 1.0,
			"_source": {
				"title": "demo-image",
				"timeFieldName": "@timestamp",
				"notExpandable": true,
			    "fields": ""
				"fieldFormatMap": "{\"file.length\":{\"id\":\"bytes\"}}"
			}
		}]
	}
}

(Jon Budzenski) #5

Ah I see, apologies I missed the second type definition. You'll likely want the query to look like this:

{
  "query": {
    "ids": {
      "type": "doc",
      "values": ["index-pattern:3851cd60-0450-11e8-8f86-9312c81e614d"] 
    }
  }
}
    query: {
      "ids": {
        "values" : ['index-pattern' + $scope.vis.indexPattern.id]
      }
    }

(Kwan) #6

thanks a lot! jbudz
the first query works for me


(system) #7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.