Arbazz Hussain
Arbazz Hussain

Reputation: 1932

How to Query just all the documents name of index in elasticsearch

PS: I'm new to elasticsearch

http://localhost:9200/indexname/domains/<mydocname>

Let's suppose we have indexname as our index and i'm uploading a lot of documents at <mydoc> with domain names ex:

http://localhost:9200/indexname/domains/google.com http://localhost:9200/indexname/domains/company.com

Looking at http://localhost:9200/indexname/_count , says that we have "count": 119687 amount of documents.

I just want my elastic search to return the document names of all 119687 entries which are domain names.

How do I achieve that and is it possible to achieve that in one single query?

Upvotes: 1

Views: 604

Answers (1)

Polynomial Proton
Polynomial Proton

Reputation: 5135

Looking at the example : http://localhost:9200/indexname/domains/google.com I am assuming your doc_type is domains and doc id/"document name" is google.com.

_id is the document name here which is always part of the response. You can use source filtering to disable source and it will show only something like below:

GET indexname/_search
{
  "_source": false
}

Output

{
...
    "hits" : [
          {
            "_index" : "indexname",
            "_type" : "domains",
            "_id" : "google.com",
            "_score" : 1.0           
          }
    ]
...
}

If documentname is a field that is mapped, then you can still use source filtering to include only that field.

 GET indexname/_search
 {
   "_source": ["documentname"]
 }

Upvotes: 1

Related Questions