Search with inject attachment - too long

Hello.

I am using elasticsearch 5.4 and inject attachment plugin. I have indexed everything and search works fine.
But the question is: when i index a lot of content files and perform search with excluding attachment.content field - the time for search is too long (more than 300ms), but when the same index doesn't have content files (it is empty) the time is 30ms?

For example: Index has 200 documents with indexed attachments content - time per one query is 300-500ms. The same query in index with the same documents with empty attachment content takes 30ms. Why does it happen? I don't make any search in content file and exclude the content in response...

{
  "from" : 0,
  "size" : 20,
  "_source" : {
    "includes" : [
      "order_id",
      "title",
      "customer_id"
    ],
    "excludes" : [ attachment.* ]
  },
  "sort" : [
    {
      "order_id" : {
        "order" : "asc"
      }
    }
  ],
    "query": {
  "bool" : {
    "must" : [
      {
        "bool" : {
          "must" : [
            {
              "bool" : {
                "filter" : [
                  {
                    "match" : {
                      "order_id" : {
                        "query" : "1",
                        "operator" : "OR",
                        "prefix_length" : 0,
                        "max_expansions" : 50,
                        "fuzzy_transpositions" : true,
                        "lenient" : false,
                        "zero_terms_query" : "NONE",
                        "boost" : 1.0
                      }
                    }
                  }
                ],
                "disable_coord" : false,
                "adjust_pure_negative" : true,
                "boost" : 1.0
              }
            }
          ],
          "disable_coord" : false,
          "adjust_pure_negative" : true,
          "boost" : 1.0
        }
      }
    ],
    "filter" : [
      {
        "term" : {
          "customer_id" : {
            "value" : "2",
            "boost" : 1.0
          }
        }
      }
    ],
    "disable_coord" : false,
    "adjust_pure_negative" : true,
    "boost" : 1.0
  }
    }
}

It's probably because elasticsearch has to read the _source field for every hit. The _source contains a lot of data in your case.

Have a look at https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-store.html for other options.

So if I make attachment.content store:false, it is not a problem for search in it. But what If I need to reindex? Does it read attachment.content if I exclude it from result hit?

i have this in my query:

 "_source" : {
"includes" : [
  "order_id",
  "title",
  "customer_id"
],
"excludes" : [ attachment.* ]

}

This is not what I meant.

I meant to explicitly set store: true on all fields you would like to retrieve (which keeps the _source intact) and then use:

GET my_index/_search
{
  "stored_fields": [ "title", "date" ] 
}

To just get back the fields you need without needing to read _source.

Thank you for replying.
I made my retrieval fields store:true, it became faster in two times. Now it takes about 150-200 ms, but it is not the same time when it is reading from source (empty attachment.content) - 30ms. What is the cause?

Can you share your query and the response?
You can trim down the last 199 hits if you are using size:200.

here it is:
    {
         "from": 0,
      "size": 20,
      "stored_fields": [
        "order_id",
        "title",
        "customer_id"
      ],
      "sort": [
        {
          "order_id": {
            "order": "asc"
          }
        }
      ],
      "query": {
        "bool": {
          "must": [
            {
              "bool": {
                "must": [
                  {
                    "bool": {
                      "filter": [
                        {
                          "match": {
                            "order_id": {
                              "query": "1",
                              "operator": "OR",
                              "prefix_length": 0,
                              "max_expansions": 50,
                              "fuzzy_transpositions": true,
                              "lenient": false,
                              "zero_terms_query": "NONE",
                              "boost": 1
                            }
                          }
                        }
                      ],
                      "disable_coord": false,
                      "adjust_pure_negative": true,
                      "boost": 1
                    }
                  }
                ],
                "disable_coord": false,
                "adjust_pure_negative": true,
                "boost": 1
              }
            }
          ],
          "filter": [
            {
              "term": {
                "customer_id": {
                  "value": "2",
                  "boost": 1
                }
              }
            }
          ],
          "disable_coord": false,
          "adjust_pure_negative": true,
          "boost": 1
        }
      }
    }

And the response?

Now it is more 300((
{
  "took": 311,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 202,
    "max_score": null,
    "hits": [
      {
        "_index": "customers",
        "_type": "order_type",
        "_id": "12",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [ 12 ],
          "order_id": [ "1" ]
        },
        "sort": [
          12
        ]
      },
      {
        "_index": "es_with_payload",
        "_type": "order_type",
        "_id": "13",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [ 13 ],
          "order_id": [ "1" ]
        },
        "sort": [ 13  ]
      },
      {
        "_index": "customers",
        "_type": "order_type",
        "_id": "14",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [ 14 ],
          "order_id": [ "1" ]
        },
        "sort": [ 14  ]
      },
      {
        "_index": "customers",
        "_type": "order_type",
        "_id": "15",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä"  ],
          "customer_id": [ 15 ],
          "order_id": [ "1" ]
        },
        "sort": [ 15 ]
      },
      {
        "_index": "customers",
        "_type": "order_type",
        "_id": "16",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [ 16 ],
          "order_id": [ "1" ]
        },
        "sort": [ 16 ]
      },
      {
        "_index": "customers",
        "_type": "order_type",
        "_id": "17",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [ 17 ],
          "order_id": [ "1" ]
        },
        "sort": [ 17 ]
      },
      {
        "_index": "customers",
        "_type": "order_type",
        "_id": "18",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [ 18 ],
          "order_id": [ "1" ]
        },
        "sort": [ 18 ]
      },
      {
        "_index": "customers",
        "_type": "order_type",
        "_id": "19",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [ 19 ],
          "order_id": [ "1" ]
        },
        "sort": [ 19 ]
      },
      {
        "_index": "customers",
        "_type": "search_type",
        "_id": "20",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [ 20 ],
          "order_id": [ "1" ]
        },
        "sort": [ 20 ]
      },
      {
        "_index": "customers",
        "_type": "order_type",
        "_id": "21",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [ 21 ],
          "order_id": [ "1" ]
        },
        "sort": [ 21 ]
      },
      {
        "_index": "customers",
        "_type": "order_type",
        "_id": "22",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [ 22 ],
          "order_id": [ "1" ] },
        "sort": [ 22 ]
      },
      {
        "_index": "customers",
        "_type": "order_type",
        "_id": "23",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [ 23 ],
          "order_id": [ "1" ]
        },
        "sort": [ 23 ]
      },
      {
        "_index": "customers",
        "_type": "order_type",
        "_id": "24",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [  24 ],
          "order_id": [ "1" ]
        },
        "sort": [ 24 ]
      },
      {
        "_index": "customers",
        "_type": "order_type",
        "_id": "25",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [ 25 ],
          "order_id": [ "1" ]
        },
        "sort": [ 25 ]
      },
      {
        "_index": "customers",
        "_type": "order_type",
        "_id": "26",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [ 26 ],
          "order_id": [ "1" ]
        },
        "sort": [ 26 ]
      },
      {
        "_index": "customers",
        "_type": "order_type",
        "_id": "27",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [ 27 ],
          "order_id": [ "1" ]
        },
        "sort": [
          27
        ]
      },
      {
        "_index": "customers",
        "_type": "order_type",
        "_id": "28",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [ 28 ],
          "order_id": [ "1" ]
        },
        "sort": [ 28 ]
      },
      {
        "_index": "customers",
        "_type": "order_type",
        "_id": "29",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [ 29 ],
          "order_id": [ "1" ]
        },
        "sort": [ 29 ]
      },
      {
        "_index": "customers",
        "_type": "order_type",
        "_id": "30",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [ 30 ],
          "order_id": [ "1" ]
        },
        "sort": [ 30 ]
      },
      {
        "_index": "customers",
        "_type": "order_type",
        "_id": "31",
        "_score": null,
        "fields": {
          "title": [ "title222 ÅÖÄåöä" ],
          "customer_id": [ 31 ],
          "order_id": [ "1" ]
        },
        "sort": [ 31 ]
      }
    ]
  }
}

Can you add profile: true in your query?

`Yes, I have done:`
{
  "from": 20,
  "size": 20,
  "profile": true,
  "stored_fields": [ "title", "customer_id", "order_id" ],
  "sort": [
{
  "customer_id": {
    "order": "asc"
  }
}
  ], .....

The time is the same((

And what if I need nested field value (leaf): I don't have it in response....

"stored_fields": [ "title", "customer_id", "order_id", "order.order_type" ]

Mapping is (index with empty attachment.content) :

    {
  "customers_2": {
    "mappings": {
      "search_type": {
        "properties": {
          "attachment": {
            "properties": {
              "content": {
                "type": "text",
                "fields": {
                  "english": {
                    "type": "text",
                    "analyzer": "english"
                  }
                }
              },
              "content_length": {
                "type": "long"
              },
              "content_type": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "language": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "title": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }
            }
          },
          "order_id": {
            "type": "keyword",
            "store": true,
            "fields": {
              "_lowercase": {
                "type": "keyword",
                "store": true,
                "normalizer": "lowercase_normalizer"
              }
            }
          },
          "customer_id": {
            "type": "long",
            "store": true
          },
          "payload": {
            "type": "text",
            "fields": {
              "english": {
                "type": "text",
                "analyzer": "english"
              }
            }
          },
          "order": {
            "type": "nested",
            "properties": {
              "order_type": {
                "type": "keyword",
                "store": true,
                "fields": {
                  "english": {
                    "type": "text",
                    "store": true,
                    "analyzer": "english"
                  }
                }
              }
            }
          },
          "title": {
            "type": "keyword",
            "store": true,
            "fields": {
              "english": {
                "type": "text",
                "store": true,
                "analyzer": "english"
              }
            }
          }
        }
      }
    }
  }
}

Response is:

{
    "took": 2,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "failed": 0
    },
    "hits": {
        "total": 1,
        "max_score": null,
        "hits": [
            {
                "_index": "customers_2",
                "_type": "search_type",
                "_id": "382",
                "_score": null,
                "fields": {
                    "title": [
                        "test"
                    ],
                    "customer_id": [
                        382
                    ],
                    "order_id": [
                        "3"
                    ]
                },
                "sort": [
                    382
                ]
            }
        ]
    }
}

Am I doing something wrong?

Can you share the result of the profiling?

Please keep from: 0 to have consistent results.

it is too large to display on one message(((

{
  "profile": {
    "shards": [
      {
        "id": "[NMZ21qTYRKeX2gaZdZUAeQ][customers][0]",
        "searches": [
          {
            "query": [
              {
                "type": "BooleanQuery",
                "description": "+(ConstantScore(order_id:1))^0.0 #instance_id:1",
                "time": "0.2175290000ms",
                "time_in_nanos": 217529,
                "breakdown": {
                  "score": 0,
                  "build_scorer_count": 10,
                  "match_count": 0,
                  "create_weight": 37886,
                  "next_doc": 16581,
                  "match": 0,
                  "create_weight_count": 1,
                  "next_doc_count": 47,
                  "score_count": 0,
                  "build_scorer": 163004,
                  "advance": 0,
                  "advance_count": 0
                },
                "children": [
                  {
                    "type": "BoostQuery",
                    "description": "(ConstantScore(order_id:1))^0.0",
                    "time": "0.07909300000ms",
                    "time_in_nanos": 79093,
                    "breakdown": {
                      "score": 0,
                      "build_scorer_count": 10,
                      "match_count": 0,
                      "create_weight": 14593,
                      "next_doc": 7852,
                      "match": 0,
                      "create_weight_count": 1,
                      "next_doc_count": 47,
                      "score_count": 0,
                      "build_scorer": 56590,
                      "advance": 0,
                      "advance_count": 0
                    },
                    "children": [
                      {
                        "type": "TermQuery",
                        "description": "order_id:1",
                        "time": "0.06480900000ms",
                        "time_in_nanos": 64809,
                        "breakdown": {
                          "score": 0,
                          "build_scorer_count": 10,
                          "match_count": 0,
                          "create_weight": 5472,
                          "next_doc": 5310,
                          "match": 0,
                          "create_weight_count": 1,
                          "next_doc_count": 47,
                          "score_count": 0,
                          "build_scorer": 53969,
                          "advance": 0,
                          "advance_count": 0
                        }
                      }
                    ]
                  },
                  {
                    "type": "TermQuery",
                    "description": "instance_id:1",
                    "time": "0.02439700000ms",
                    "time_in_nanos": 24397,
                    "breakdown": {
                      "score": 0,
                      "build_scorer_count": 5,
                      "match_count": 0,
                      "create_weight": 1094,
                      "next_doc": 0,
                      "match": 0,
                      "create_weight_count": 1,
                      "next_doc_count": 0,
                      "score_count": 0,
                      "build_scorer": 19945,
                      "advance": 3305,
                      "advance_count": 47
                    }
                  }
                ]
              }
            ],
            "rewrite_time": 83373,
            "collector": [
              {
                "name": "CancellableCollector",
                "reason": "search_cancelled",
                "time": "0.03885200000ms",
                "time_in_nanos": 38852,
                "children": [
                  {
                    "name": "SimpleFieldCollector",
                    "reason": "search_top_hits",
                    "time": "0.02961100000ms",
                    "time_in_nanos": 29611
                  }
                ]
              }
            ]
          }
        ],
        "aggregations": []
      },
      {
        "id": "[NMZ21qTYRKeX2gaZdZUAeQ][customers][1]",
        "searches": [
          {
            "query": [
              {
                "type": "BooleanQuery",
                "description": "+(+(ConstantScore(order_id:1))^0.0 #instance_id:1) #ConstantScore(_type:search_type)",
                "time": "0.3049310000ms",
                "time_in_nanos": 304931,
                "breakdown": {
                  "score": 0,
                  "build_scorer_count": 9,
                  "match_count": 0,
                  "create_weight": 115102,
                  "next_doc": 19311,
                  "match": 0,
                  "create_weight_count": 1,
                  "next_doc_count": 41,
                  "score_count": 0,
                  "build_scorer": 170467,
                  "advance": 0,
                  "advance_count": 0
                },
                "children": [
                  {
                    "type": "BooleanQuery",
                    "description": "+(ConstantScore(order_id:1))^0.0 #instance_id:1",
                    "time": "0.2150050000ms",
                    "time_in_nanos": 215005,
                    "breakdown": {
                      "score": 0,
                      "build_scorer_count": 9,
                      "match_count": 0,
                      "create_weight": 97026,
                      "next_doc": 11276,
                      "match": 0,
                      "create_weight_count": 1,
                      "next_doc_count": 41,
                      "score_count": 0,
                      "build_scorer": 106652,
                      "advance": 0,
                      "advance_count": 0
                    },

Second part:

"children": [
                      {
                        "type": "BoostQuery",
                        "description": "(ConstantScore(order_id:1))^0.0",
                        "time": "0.1034210000ms",
                        "time_in_nanos": 103421,
                        "breakdown": {
                          "score": 0,
                          "build_scorer_count": 9,
                          "match_count": 0,
                          "create_weight": 56025,
                          "next_doc": 5620,
                          "match": 0,
                          "create_weight_count": 1,
                          "next_doc_count": 41,
                          "score_count": 0,
                          "build_scorer": 41725,
                          "advance": 0,
                          "advance_count": 0
                        },
                        "children": [
                          {
                            "type": "TermQuery",
                            "description": "order_id:1",
                            "time": "0.04615000000ms",
                            "time_in_nanos": 46150,
                            "breakdown": {
                              "score": 0,
                              "build_scorer_count": 9,
                              "match_count": 0,
                              "create_weight": 2763,
                              "next_doc": 3365,
                              "match": 0,
                              "create_weight_count": 1,
                              "next_doc_count": 41,
                              "score_count": 0,
                              "build_scorer": 39971,
                              "advance": 0,
                              "advance_count": 0
                            }
                          }
                        ]
                      },
                      {
                        "type": "TermQuery",
                        "description": "instance_id:1",
                        "time": "0.01908100000ms",
                        "time_in_nanos": 19081,
                        "breakdown": {
                          "score": 0,
                          "build_scorer_count": 5,
                          "match_count": 0,
                          "create_weight": 1159,
                          "next_doc": 0,
                          "match": 0,
                          "create_weight_count": 1,
                          "next_doc_count": 0,
                          "score_count": 0,
                          "build_scorer": 15803,
                          "advance": 2072,
                          "advance_count": 41
                        }
                      }
                    ]
                  },
                  {
                    "type": "ConstantScoreQuery",
                    "description": "ConstantScore(_type:search_type)",
                    "time": "0.02794800000ms",
                    "time_in_nanos": 27948,
                    "breakdown": {
                      "score": 0,
                      "build_scorer_count": 5,
                      "match_count": 0,
                      "create_weight": 6100,
                      "next_doc": 0,
                      "match": 0,
                      "create_weight_count": 1,
                      "next_doc_count": 0,
                      "score_count": 0,
                      "build_scorer": 17489,
                      "advance": 4312,
                      "advance_count": 41
                    },
                    "children": [
                      {
                        "type": "TermQuery",
                        "description": "_type:search_type",
                        "time": "0.01858000000ms",
                        "time_in_nanos": 18580,
                        "breakdown": {
                          "score": 0,
                          "build_scorer_count": 5,
                          "match_count": 0,
                          "create_weight": 782,
                          "next_doc": 0,
                          "match": 0,
                          "create_weight_count": 1,
                          "next_doc_count": 0,
                          "score_count": 0,
                          "build_scorer": 15343,
                          "advance": 2408,
                          "advance_count": 41
                        }
                      }
                    ]
                  }
                ]
              }
            ],
            "rewrite_time": 64193,
            "collector": [
              {
                "name": "CancellableCollector",
                "reason": "search_cancelled",
                "time": "0.04686100000ms",
                "time_in_nanos": 46861,
                "children": [
                  {
                    "name": "SimpleFieldCollector",
                    "reason": "search_top_hits",
                    "time": "0.03975000000ms",
                    "time_in_nanos": 39750
                  }
                ]
              }
            ]
          }
        ],
        "aggregations": []
      },

Third part:

 {
        "id": "[NMZ21qTYRKeX2gaZdZUAeQ][customers][2]",
        "searches": [
          {
            "query": [
              {
                "type": "BooleanQuery",
                "description": "+(ConstantScore(order_id:1))^0.0 #instance_id:1",
                "time": "0.2139990000ms",
                "time_in_nanos": 213999,
                "breakdown": {
                  "score": 0,
                  "build_scorer_count": 15,
                  "match_count": 0,
                  "create_weight": 20158,
                  "next_doc": 14183,
                  "match": 0,
                  "create_weight_count": 1,
                  "next_doc_count": 45,
                  "score_count": 0,
                  "build_scorer": 179597,
                  "advance": 0,
                  "advance_count": 0
                },
                "children": [
                  {
                    "type": "BoostQuery",
                    "description": "(ConstantScore(order_id:1))^0.0",
                    "time": "0.08355700000ms",
                    "time_in_nanos": 83557,
                    "breakdown": {
                      "score": 0,
                      "build_scorer_count": 15,
                      "match_count": 0,
                      "create_weight": 7477,
                      "next_doc": 6657,
                      "match": 0,
                      "create_weight_count": 1,
                      "next_doc_count": 45,
                      "score_count": 0,
                      "build_scorer": 69362,
                      "advance": 0,
                      "advance_count": 0
                    },
                    "children": [
                      {
                        "type": "TermQuery",
                        "description": "order_id:1",
                        "time": "0.07254600000ms",
                        "time_in_nanos": 72546,
                        "breakdown": {
                          "score": 0,
                          "build_scorer_count": 15,
                          "match_count": 0,
                          "create_weight": 2520,
                          "next_doc": 4258,
                          "match": 0,
                          "create_weight_count": 1,
                          "next_doc_count": 45,
                          "score_count": 0,
                          "build_scorer": 65707,
                          "advance": 0,
                          "advance_count": 0
                        }
                      }
                    ]
                  },
                  {
                    "type": "TermQuery",
                    "description": "instance_id:1",
                    "time": "0.03632600000ms",
                    "time_in_nanos": 36326,
                    "breakdown": {
                      "score": 0,
                      "build_scorer_count": 5,
                      "match_count": 0,
                      "create_weight": 505,
                      "next_doc": 0,
                      "match": 0,
                      "create_weight_count": 1,
                      "next_doc_count": 0,
                      "score_count": 0,
                      "build_scorer": 32820,
                      "advance": 2950,
                      "advance_count": 45
                    }
                  }
                ]
              }
            ],
            "rewrite_time": 85925,
            "collector": [
              {
                "name": "CancellableCollector",
                "reason": "search_cancelled",
                "time": "0.04732800000ms",
                "time_in_nanos": 47328,
                "children": [
                  {
                    "name": "SimpleFieldCollector",
                    "reason": "search_top_hits",
                    "time": "0.03936300000ms",
                    "time_in_nanos": 39363
                  }
                ]
              }
            ]
          }
        ],
        "aggregations": []
      },

fourth:

  {
        "id": "[NMZ21qTYRKeX2gaZdZUAeQ][customers][3]",
        "searches": [
          {
            "query": [
              {
                "type": "BooleanQuery",
                "description": "+(ConstantScore(order_id:1))^0.0 #instance_id:1",
                "time": "0.3465360000ms",
                "time_in_nanos": 346536,
                "breakdown": {
                  "score": 0,
                  "build_scorer_count": 14,
                  "match_count": 0,
                  "create_weight": 93084,
                  "next_doc": 29685,
                  "match": 0,
                  "create_weight_count": 1,
                  "next_doc_count": 42,
                  "score_count": 0,
                  "build_scorer": 223710,
                  "advance": 0,
                  "advance_count": 0
                },
                "children": [
                  {
                    "type": "BoostQuery",
                    "description": "(ConstantScore(order_id:1))^0.0",
                    "time": "0.1340710000ms",
                    "time_in_nanos": 134071,
                    "breakdown": {
                      "score": 0,
                      "build_scorer_count": 14,
                      "match_count": 0,
                      "create_weight": 34208,
                      "next_doc": 12964,
                      "match": 0,
                      "create_weight_count": 1,
                      "next_doc_count": 42,
                      "score_count": 0,
                      "build_scorer": 86842,
                      "advance": 0,
                      "advance_count": 0
                    },
                    "children": [
                      {
                        "type": "TermQuery",
                        "description": "order_id:1",
                        "time": "0.09555600000ms",
                        "time_in_nanos": 95556,
                        "breakdown": {
                          "score": 0,
                          "build_scorer_count": 14,
                          "match_count": 0,
                          "create_weight": 11517,
                          "next_doc": 7072,
                          "match": 0,
                          "create_weight_count": 1,
                          "next_doc_count": 42,
                          "score_count": 0,
                          "build_scorer": 76910,
                          "advance": 0,
                          "advance_count": 0
                        }
                      }
                    ]
                  },
                  {
                    "type": "TermQuery",
                    "description": "instance_id:1",
                    "time": "0.03845500000ms",
                    "time_in_nanos": 38455,
                    "breakdown": {
                      "score": 0,
                      "build_scorer_count": 5,
                      "match_count": 0,
                      "create_weight": 6119,
                      "next_doc": 0,
                      "match": 0,
                      "create_weight_count": 1,
                      "next_doc_count": 0,
                      "score_count": 0,
                      "build_scorer": 27789,
                      "advance": 4499,
                      "advance_count": 42
                    }
                  }
                ]
              }
            ],
            "rewrite_time": 157969,
            "collector": [
              {
                "name": "CancellableCollector",
                "reason": "search_cancelled",
                "time": "0.1509110000ms",
                "time_in_nanos": 150911,
                "children": [
                  {
                    "name": "SimpleFieldCollector",
                    "reason": "search_top_hits",
                    "time": "0.07625200000ms",
                    "time_in_nanos": 76252
                  }
                ]
              }
            ]
          }
        ],
        "aggregations": []
      },
The last:
     {  "id": "[NMZ21qTYRKeX2gaZdZUAeQ][customers][4]",
  "searches": [
    { "query": [
  {   "type": "BooleanQuery",
    "description": "+(+(ConstantScore(order_id:1))^0.0 #instance_id:1) #ConstantScore(_type:search_type)",
    "time": "0.2717480000ms",
    "time_in_nanos": 271748,
    "breakdown": {
"score": 0,
"build_scorer_count": 15,
"match_count": 0,
"create_weight": 37174,
"next_doc": 25490,
"match": 0,
"create_weight_count": 1,
"next_doc_count": 53,
"score_count": 0,
"build_scorer": 209015,
"advance": 0,
"advance_count": 0
    },
    "children": [
{ "type": "BooleanQuery",
  "description": "+(ConstantScore(order_id:1))^0.0 #instance_id:1",
  "time": "0.1603020000ms",
  "time_in_nanos": 160302,
  "breakdown": {
    "score": 0,
    "build_scorer_count": 15,
    "match_count": 0,
    "create_weight": 19908,
    "next_doc": 14761,
    "match": 0,
    "create_weight_count": 1,
    "next_doc_count": 53,
    "score_count": 0,
    "build_scorer": 125564,
    "advance": 0,
    "advance_count": 0
  },
  "children": [
    { "type": "BoostQuery",
"description": "(ConstantScore(order_id:1))^0.0",
"time": "0.07173500000ms",
"time_in_nanos": 71735,
"breakdown": {
  "score": 0,
  "build_scorer_count": 15,
  "match_count": 0,
  "create_weight": 9261,
  "next_doc": 7641,
  "match": 0,
  "create_weight_count": 1,
  "next_doc_count": 53,
  "score_count": 0,
  "build_scorer": 54764,
  "advance": 0,
  "advance_count": 0
},
"children": [
  { "type": "TermQuery",
    "description": "order_id:1",
    "time": "0.06040200000ms",
    "time_in_nanos": 60402,
    "breakdown": {
"score": 0,
"build_scorer_count": 15,
"match_count": 0,
"create_weight": 3446,
"next_doc": 4692,
"match": 0,
"create_weight_count": 1,
"next_doc_count": 53,
"score_count": 0,
"build_scorer": 52195,
"advance": 0,
"advance_count": 0 } } ] },
    {
"type": "TermQuery",
"description": "instance_id:1",
"time": "0.02033800000ms",
"time_in_nanos": 20338,
"breakdown": {
  "score": 0,
  "build_scorer_count": 6,
  "match_count": 0,
  "create_weight": 783,
  "next_doc": 0,
  "match": 0,
  "create_weight_count": 1,
  "next_doc_count": 0,
  "score_count": 0,
  "build_scorer": 16962,
  "advance": 2533,
  "advance_count": 53 } }  ] },
{
  "type": "ConstantScoreQuery",
  "description": "ConstantScore(_type:search_type)",
  "time": "0.03119400000ms",
  "time_in_nanos": 31194,
  "breakdown": {
    "score": 0,
    "build_scorer_count": 6,
    "match_count": 0,
    "create_weight": 4321,
    "next_doc": 0,
    "match": 0,
    "create_weight_count": 1,
    "next_doc_count": 0,
    "score_count": 0,
    "build_scorer": 21213,
    "advance": 5600,
    "advance_count": 53
  },
  "children": [
    { "type": "TermQuery",
"description": "_type:search_type",
"time": "0.02258300000ms",
"time_in_nanos": 22583,
"breakdown": {
   "score": 0,
  "build_scorer_count": 6,
  "match_count": 0,
  "create_weight": 801,
  "next_doc": 0,
  "match": 0,
  "create_weight_count": 1,
  "next_doc_count": 0,
  "score_count": 0,
  "build_scorer": 18563,
  "advance": 3159,
  "advance_count": 53  }   } ] } ] }
],
"rewrite_time": 89507,
"collector": [
  {
    "name": "CancellableCollector",
    "reason": "search_cancelled",
    "time": "0.03830000000ms",
    "time_in_nanos": 38300,
    "children": [
  { "name": "SimpleFieldCollector",
    "reason": "search_top_hits",
    "time": "0.03101400000ms",
    "time_in_nanos": 31014  }   ] }  ] }
 ], "aggregations": [] }
   ] } }

what is about nested field as stored field that I described above profile?

is it true?
The stored_fields parameter is about fields that are explicitly marked as stored in the mapping, which is off by default and generally not recommended. Use source filtering instead to select subsets of the original source document to be returned.

But if i ask it from source in my query than I come back to read the whole _source and the time is increasing as before? Even if i use:

"stored_fields": [ "title", "customer_id", "order_id" ],
"_source" : {
"includes": [ "order.order_type" ],
"excludes": []
}

Help me, please, i have time limits to solve it.

You can share full output on gist.github.com instead.

I did not see anything obvious. May be @jpountz has an idea?