0

I use this command, which should match all documents:

curl -XGET 'localhost:9200/users/_search?pretty' -H 'Content-Type: application/json' -d'
{
  "query": { "match_all": {} }
}
'

I get this response:

{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : null,
    "hits" : [ ]
  }
}

But I'm 99.9% sure I have documents on that index. If I am right, why isn't it showing the matches? If I am wrong, how can I confirm this?

1 Answer 1

1

You should be able to determine what's happening if you know (a) where all your documents are being stored and (b) what the server thinks the 'users' index actually is.

For the first question, you can hit the _cat/indices endpoint to see how many documents you have in each index (the "docs.count" column):

$curl -XGET 'http://localhost:9200/_cat/indices?v'

health status index                    pri rep docs.count docs.deleted store.size pri.store.size
green  open   query                      1   0          0            0       159b           159b
green  open   some_index                 1   0         54            0     24.7kb         24.7kb
green  open   autocomplete               1   0          0            0       159b           159b
green  open   test_index                 2   0      10065         4824      7.9mb          7.9mb

For the second question, check the aliases defined on your server. It's possible that "users" has been defined as an alias to an index that doesn't have any documents, or it's possible that a filtered alias has been defined on that index with a filter that is excluding all of your documents (many aliases have date-related filters that will exclude all documents outside of a very specific date range). To check for the presence of aliases you can use

$curl -XGET 'http://localhost:9200/_aliases?pretty=true'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.