muziyoshiz  
                (Masahiro Yoshizawa)
               
                 
              
                  
                    October 24, 2019,  3:50am
                   
                   
              1 
               
             
            
              Hello Elasticsearch Team,
In our use case, we want to get only document IDs of the matched documents as a result of search API /_search.
But when I call search API with a query including "sort" field, the response contains unnecessary hits.hits.sort field as follows.
{
  "took": 6,
  "timed_out": false,
  "_shards": {
    "total": 6,
    "successful": 6,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": null,
    "hits": [
      {
        "_index": "example1",
        "_type": "_doc",
        "_id": "12345",
        "_score": null,
        "sort": [
          "Unnecessary keyword value",
          "12345"
        ]
      }
    ]
  }
}
 
"_source":false was ignored for the hits.hits.sort field. 
In our use case, the keyword field for sort may contain long keyword. So it consumes Java heap space uselessly.
Can I remove hits.hits.sort field itself or the keyword text in the field by any option?
Thanks.
             
            
               
               
               
            
            
           
          
            
              
                dadoonet  
                (David Pilato)
               
              
                  
                    October 24, 2019,  8:23am
                   
                   
              2 
               
             
            
              Welcome! I don't think you can. That being said I don't think that displaying 10 sort values is the problem.
You should read https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#_memory_considerations 
It says that you are loading in memory all the sort values. Even though you are displaying only 10 afterwards.
May be using index sorting could help? See https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-index-sorting.html 
             
            
               
               
               
            
            
           
          
            
              
                muziyoshiz  
                (Masahiro Yoshizawa)
               
              
                  
                    October 24, 2019,  8:51am
                   
                   
              3 
               
             
            
              Thank you very much!
Sorry for my incomplete explanation. we used bigger size than default value (10). 
So the size of the response came to an issue.
After my post, I found filter_path parameter. It may be the solution for what we wanted to do. 
https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#common-options-response-filtering 
             
            
               
               
               
            
            
           
          
            
              
                dadoonet  
                (David Pilato)
               
              
                  
                    October 24, 2019,  2:34pm
                   
                   
              4 
               
             
            
              May be but the filtering will not happen early though. So big objects will still being built in memory.
             
            
               
               
               
            
            
           
          
            
              
                system  
                (system)
                  Closed 
               
              
                  
                    November 21, 2019,  2:34pm
                   
                   
              5 
               
             
            
              This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.