Home > Mobile >  Retrieve all metadata fields of a document in the search - elastic search
Retrieve all metadata fields of a document in the search - elastic search

Time:12-18

I am trying to retrieve all the metadata fields that a document has in the elasticsearch. Is there a way to force the query to show them all in the search results?

ex:

GET /search-test/_search
{
"fields": ["_id","_doc_count","_field_names","_ignored","_index","_meta"],
   "query": {
    "bool":{
    "must":[
        {"match" : { "_id":"11085" }}
      ]
  }
  }
}

CodePudding user response:

Did you try with * on _source field like this?

GET /search-test/_search
{
  "_source": ["*"],
  "query": {
    "bool": {
      "must": [
        {"match" : { "_id":"11085" }}
      ]
    }
  }
}

OR with "_source": true

GET search-test/_search
{
  "_source": true, 
  "query": {
        "bool": {
          "must": [
            {"match" : { "_id":"11085" }}
          ]
        }
      }
}

CodePudding user response:

It by default shows all the results.

If you want a particular result then add "include":["_id","_doc_count","_field_names","_ignored","_index","_meta"]

GET /search-test/_search
{
  "query": {
    "bool":{
    "must":[
        {"match" : { "_id":"11085" }}
      ]
  }
  }
}
  • Related