elastic icon indicating copy to clipboard operation
elastic copied to clipboard

Search Returns 404 with Multiple Indices using Date Math Resolution

Open zanes2016 opened this issue 6 years ago • 2 comments

We should support multiple index searches with date math index name resolution. However, this does not work if one or more index uses date math resolution. Searches of multiple date math indices work fine using curl, but the golang elastic API returns a 404 error from ES.

Which version of Elastic are you using?

[latest commit] elastic.v6 (for Elasticsearch 6.x)

Expected behavior

Be able to specify and return search results for multiple indices using date math index name resolution. This works correctly with curl.

Example URL

https://host/<counters-{now/d}>,<counters-{now-1d/d}>/_search

This should return two indices for the current day and past day.

Expected Return (shortened)

{
    "counters-2019.01.10": {
        "aliases": {},
        "mappings": {
            "doc": {
                ...
            }
        },
        "settings": {
            "index": {
                "creation_date": "1547078418563",
                "number_of_replicas": "1",
                "number_of_shards": "5",
               ...
            }
        }
    },
    "counters-2019.01.11": {
        "aliases": {},
        "mappings": {
            "doc": {
                ...
            }
        },
        "settings": {
            "index": {
                "creation_date": "1547164803672",
                "number_of_replicas": "1",
                "number_of_shards": "5",
               ...
                }
            }
        }
    }
}

Again, this works fine when using curl.

Actual behavior

I would expect to be able to specify multiple indices with date math resolution in a single search query. However, ES returns a 404 error: elastic: Error 400 (Bad Request)

Code

        searchResult, err := client.Search().
		Index("<counters-{now/d}>",  "<counters-{now-1d/d}>").
		Query(elastic.NewMatchAllQuery()).
		Size(0).
		Pretty(true).
		Do(context.Background())
	if err != nil {
		glog.Errorf("%s: %+v", err, searchResult)
		return err
	}
...
elastic: Error 400 (Bad Request)
...

Any steps to reproduce the behavior?

This happens consistently when using the client API. Works fine from curl.

zanes2016 avatar Jan 11 '19 21:01 zanes2016

Hmm... on a gut level this looks like an encoding issue. Will look at it in the next release.

olivere avatar Jan 15 '19 11:01 olivere

@zanes2016 I've added a test for this and cannot reproduce. Can you have a look?

olivere avatar Jan 27 '19 15:01 olivere