Unified highlighter performance regression between 6.8 and 7.17

After upgrading from Elasticsearch 6.8 to 7.17 we noticed that highlighting queries started taking several seconds instead of milliseconds.

We have many hundreds of fields in our mapping and the data is sparsely populated.

I have added here a minimal test case that shows the difference (mapping is for 7, insert "_doc" wrapper for 6.8):

# Mapping for ES7, ES8
PUT my-index
{"mappings":{"properties":{"field_001":{"type":"text"},"field_002":{"type":"text"},"field_003":{"type":"text"},"field_004":{"type":"text"},"field_005":{"type":"text"},"field_006":{"type":"text"},"field_007":{"type":"text"},"field_008":{"type":"text"},"field_009":{"type":"text"},"field_010":{"type":"text"},"field_011":{"type":"text"},"field_012":{"type":"text"},"field_013":{"type":"text"},"field_014":{"type":"text"},"field_015":{"type":"text"},"field_016":{"type":"text"},"field_017":{"type":"text"},"field_018":{"type":"text"},"field_019":{"type":"text"},"field_020":{"type":"text"},"field_021":{"type":"text"},"field_022":{"type":"text"},"field_023":{"type":"text"},"field_024":{"type":"text"},"field_025":{"type":"text"},"field_026":{"type":"text"},"field_027":{"type":"text"},"field_028":{"type":"text"},"field_029":{"type":"text"},"field_030":{"type":"text"},"field_031":{"type":"text"},"field_032":{"type":"text"},"field_033":{"type":"text"},"field_034":{"type":"text"},"field_035":{"type":"text"},"field_036":{"type":"text"},"field_037":{"type":"text"},"field_038":{"type":"text"},"field_039":{"type":"text"},"field_040":{"type":"text"},"field_041":{"type":"text"},"field_042":{"type":"text"},"field_043":{"type":"text"},"field_044":{"type":"text"},"field_045":{"type":"text"},"field_046":{"type":"text"},"field_047":{"type":"text"},"field_048":{"type":"text"},"field_049":{"type":"text"},"field_050":{"type":"text"},"field_051":{"type":"text"},"field_052":{"type":"text"},"field_053":{"type":"text"},"field_054":{"type":"text"},"field_055":{"type":"text"},"field_056":{"type":"text"},"field_057":{"type":"text"},"field_058":{"type":"text"},"field_059":{"type":"text"},"field_060":{"type":"text"},"field_061":{"type":"text"},"field_062":{"type":"text"},"field_063":{"type":"text"},"field_064":{"type":"text"},"field_065":{"type":"text"},"field_066":{"type":"text"},"field_067":{"type":"text"},"field_068":{"type":"text"},"field_069":{"type":"text"},"field_070":{"type":"text"},"field_071":{"type":"text"},"field_072":{"type":"text"},"field_073":{"type":"text"},"field_074":{"type":"text"},"field_075":{"type":"text"},"field_076":{"type":"text"},"field_077":{"type":"text"},"field_078":{"type":"text"},"field_079":{"type":"text"},"field_080":{"type":"text"},"field_081":{"type":"text"},"field_082":{"type":"text"},"field_083":{"type":"text"},"field_084":{"type":"text"},"field_085":{"type":"text"},"field_086":{"type":"text"},"field_087":{"type":"text"},"field_088":{"type":"text"},"field_089":{"type":"text"},"field_090":{"type":"text"},"field_091":{"type":"text"},"field_092":{"type":"text"},"field_093":{"type":"text"},"field_094":{"type":"text"},"field_095":{"type":"text"},"field_096":{"type":"text"},"field_097":{"type":"text"},"field_098":{"type":"text"},"field_099":{"type":"text"},"field_100":{"type":"text"},"field_101":{"type":"text"},"field_102":{"type":"text"},"field_103":{"type":"text"},"field_104":{"type":"text"},"field_105":{"type":"text"},"field_106":{"type":"text"},"field_107":{"type":"text"},"field_108":{"type":"text"},"field_109":{"type":"text"},"field_110":{"type":"text"},"field_111":{"type":"text"},"field_112":{"type":"text"},"field_113":{"type":"text"},"field_114":{"type":"text"},"field_115":{"type":"text"},"field_116":{"type":"text"},"field_117":{"type":"text"},"field_118":{"type":"text"},"field_119":{"type":"text"},"field_120":{"type":"text"},"field_121":{"type":"text"},"field_122":{"type":"text"},"field_123":{"type":"text"},"field_124":{"type":"text"},"field_125":{"type":"text"},"field_126":{"type":"text"},"field_127":{"type":"text"},"field_128":{"type":"text"},"field_129":{"type":"text"},"field_130":{"type":"text"},"field_131":{"type":"text"},"field_132":{"type":"text"},"field_133":{"type":"text"},"field_134":{"type":"text"},"field_135":{"type":"text"},"field_136":{"type":"text"},"field_137":{"type":"text"},"field_138":{"type":"text"},"field_139":{"type":"text"},"field_140":{"type":"text"},"field_141":{"type":"text"},"field_142":{"type":"text"},"field_143":{"type":"text"},"field_144":{"type":"text"},"field_145":{"type":"text"},"field_146":{"type":"text"},"field_147":{"type":"text"},"field_148":{"type":"text"},"field_149":{"type":"text"},"field_150":{"type":"text"},"field_151":{"type":"text"},"field_152":{"type":"text"},"field_153":{"type":"text"},"field_154":{"type":"text"},"field_155":{"type":"text"},"field_156":{"type":"text"},"field_157":{"type":"text"},"field_158":{"type":"text"},"field_159":{"type":"text"},"field_160":{"type":"text"},"field_161":{"type":"text"},"field_162":{"type":"text"},"field_163":{"type":"text"},"field_164":{"type":"text"},"field_165":{"type":"text"},"field_166":{"type":"text"},"field_167":{"type":"text"},"field_168":{"type":"text"},"field_169":{"type":"text"},"field_170":{"type":"text"},"field_171":{"type":"text"},"field_172":{"type":"text"},"field_173":{"type":"text"},"field_174":{"type":"text"},"field_175":{"type":"text"},"field_176":{"type":"text"},"field_177":{"type":"text"},"field_178":{"type":"text"},"field_179":{"type":"text"},"field_180":{"type":"text"},"field_181":{"type":"text"},"field_182":{"type":"text"},"field_183":{"type":"text"},"field_184":{"type":"text"},"field_185":{"type":"text"},"field_186":{"type":"text"},"field_187":{"type":"text"},"field_188":{"type":"text"},"field_189":{"type":"text"},"field_190":{"type":"text"},"field_191":{"type":"text"},"field_192":{"type":"text"},"field_193":{"type":"text"},"field_194":{"type":"text"},"field_195":{"type":"text"},"field_196":{"type":"text"},"field_197":{"type":"text"},"field_198":{"type":"text"},"field_199":{"type":"text"},"field_200":{"type":"text"},"field_201":{"type":"text"},"field_202":{"type":"text"},"field_203":{"type":"text"},"field_204":{"type":"text"},"field_205":{"type":"text"},"field_206":{"type":"text"},"field_207":{"type":"text"},"field_208":{"type":"text"},"field_209":{"type":"text"},"field_210":{"type":"text"},"field_211":{"type":"text"},"field_212":{"type":"text"},"field_213":{"type":"text"},"field_214":{"type":"text"},"field_215":{"type":"text"},"field_216":{"type":"text"},"field_217":{"type":"text"},"field_218":{"type":"text"},"field_219":{"type":"text"},"field_220":{"type":"text"},"field_221":{"type":"text"},"field_222":{"type":"text"},"field_223":{"type":"text"},"field_224":{"type":"text"},"field_225":{"type":"text"},"field_226":{"type":"text"},"field_227":{"type":"text"},"field_228":{"type":"text"},"field_229":{"type":"text"},"field_230":{"type":"text"},"field_231":{"type":"text"},"field_232":{"type":"text"},"field_233":{"type":"text"},"field_234":{"type":"text"},"field_235":{"type":"text"},"field_236":{"type":"text"},"field_237":{"type":"text"},"field_238":{"type":"text"},"field_239":{"type":"text"},"field_240":{"type":"text"},"field_241":{"type":"text"},"field_242":{"type":"text"},"field_243":{"type":"text"},"field_244":{"type":"text"},"field_245":{"type":"text"},"field_246":{"type":"text"},"field_247":{"type":"text"},"field_248":{"type":"text"},"field_249":{"type":"text"},"field_250":{"type":"text"},"field_251":{"type":"text"},"field_252":{"type":"text"},"field_253":{"type":"text"},"field_254":{"type":"text"},"field_255":{"type":"text"},"field_256":{"type":"text"},"field_257":{"type":"text"},"field_258":{"type":"text"},"field_259":{"type":"text"},"field_260":{"type":"text"},"field_261":{"type":"text"},"field_262":{"type":"text"},"field_263":{"type":"text"},"field_264":{"type":"text"},"field_265":{"type":"text"},"field_266":{"type":"text"},"field_267":{"type":"text"},"field_268":{"type":"text"},"field_269":{"type":"text"},"field_270":{"type":"text"},"field_271":{"type":"text"},"field_272":{"type":"text"},"field_273":{"type":"text"},"field_274":{"type":"text"},"field_275":{"type":"text"},"field_276":{"type":"text"},"field_277":{"type":"text"},"field_278":{"type":"text"},"field_279":{"type":"text"},"field_280":{"type":"text"},"field_281":{"type":"text"},"field_282":{"type":"text"},"field_283":{"type":"text"},"field_284":{"type":"text"},"field_285":{"type":"text"},"field_286":{"type":"text"},"field_287":{"type":"text"},"field_288":{"type":"text"},"field_289":{"type":"text"},"field_290":{"type":"text"},"field_291":{"type":"text"},"field_292":{"type":"text"},"field_293":{"type":"text"},"field_294":{"type":"text"},"field_295":{"type":"text"},"field_296":{"type":"text"},"field_297":{"type":"text"},"field_298":{"type":"text"},"field_299":{"type":"text"},"field_300":{"type":"text"},"field_301":{"type":"text"},"field_302":{"type":"text"},"field_303":{"type":"text"},"field_304":{"type":"text"},"field_305":{"type":"text"},"field_306":{"type":"text"},"field_307":{"type":"text"},"field_308":{"type":"text"},"field_309":{"type":"text"},"field_310":{"type":"text"},"field_311":{"type":"text"},"field_312":{"type":"text"},"field_313":{"type":"text"},"field_314":{"type":"text"},"field_315":{"type":"text"},"field_316":{"type":"text"},"field_317":{"type":"text"},"field_318":{"type":"text"},"field_319":{"type":"text"},"field_320":{"type":"text"},"field_321":{"type":"text"},"field_322":{"type":"text"},"field_323":{"type":"text"},"field_324":{"type":"text"},"field_325":{"type":"text"},"field_326":{"type":"text"},"field_327":{"type":"text"},"field_328":{"type":"text"},"field_329":{"type":"text"},"field_330":{"type":"text"},"field_331":{"type":"text"},"field_332":{"type":"text"},"field_333":{"type":"text"},"field_334":{"type":"text"},"field_335":{"type":"text"},"field_336":{"type":"text"},"field_337":{"type":"text"},"field_338":{"type":"text"},"field_339":{"type":"text"},"field_340":{"type":"text"},"field_341":{"type":"text"},"field_342":{"type":"text"},"field_343":{"type":"text"},"field_344":{"type":"text"},"field_345":{"type":"text"},"field_346":{"type":"text"},"field_347":{"type":"text"},"field_348":{"type":"text"},"field_349":{"type":"text"},"field_350":{"type":"text"},"field_351":{"type":"text"},"field_352":{"type":"text"},"field_353":{"type":"text"},"field_354":{"type":"text"},"field_355":{"type":"text"},"field_356":{"type":"text"},"field_357":{"type":"text"},"field_358":{"type":"text"},"field_359":{"type":"text"},"field_360":{"type":"text"},"field_361":{"type":"text"},"field_362":{"type":"text"},"field_363":{"type":"text"},"field_364":{"type":"text"},"field_365":{"type":"text"},"field_366":{"type":"text"},"field_367":{"type":"text"},"field_368":{"type":"text"},"field_369":{"type":"text"},"field_370":{"type":"text"},"field_371":{"type":"text"},"field_372":{"type":"text"},"field_373":{"type":"text"},"field_374":{"type":"text"},"field_375":{"type":"text"},"field_376":{"type":"text"},"field_377":{"type":"text"},"field_378":{"type":"text"},"field_379":{"type":"text"},"field_380":{"type":"text"},"field_381":{"type":"text"},"field_382":{"type":"text"},"field_383":{"type":"text"},"field_384":{"type":"text"},"field_385":{"type":"text"},"field_386":{"type":"text"},"field_387":{"type":"text"},"field_388":{"type":"text"},"field_389":{"type":"text"},"field_390":{"type":"text"},"field_391":{"type":"text"},"field_392":{"type":"text"},"field_393":{"type":"text"},"field_394":{"type":"text"},"field_395":{"type":"text"},"field_396":{"type":"text"},"field_397":{"type":"text"},"field_398":{"type":"text"},"field_399":{"type":"text"},"field_400":{"type":"text"},"field_401":{"type":"text"},"field_402":{"type":"text"},"field_403":{"type":"text"},"field_404":{"type":"text"},"field_405":{"type":"text"},"field_406":{"type":"text"},"field_407":{"type":"text"},"field_408":{"type":"text"},"field_409":{"type":"text"},"field_410":{"type":"text"},"field_411":{"type":"text"},"field_412":{"type":"text"},"field_413":{"type":"text"},"field_414":{"type":"text"},"field_415":{"type":"text"},"field_416":{"type":"text"},"field_417":{"type":"text"},"field_418":{"type":"text"},"field_419":{"type":"text"},"field_420":{"type":"text"},"field_421":{"type":"text"},"field_422":{"type":"text"},"field_423":{"type":"text"},"field_424":{"type":"text"},"field_425":{"type":"text"},"field_426":{"type":"text"},"field_427":{"type":"text"},"field_428":{"type":"text"},"field_429":{"type":"text"},"field_430":{"type":"text"},"field_431":{"type":"text"},"field_432":{"type":"text"},"field_433":{"type":"text"},"field_434":{"type":"text"},"field_435":{"type":"text"},"field_436":{"type":"text"},"field_437":{"type":"text"},"field_438":{"type":"text"},"field_439":{"type":"text"},"field_440":{"type":"text"},"field_441":{"type":"text"},"field_442":{"type":"text"},"field_443":{"type":"text"},"field_444":{"type":"text"},"field_445":{"type":"text"},"field_446":{"type":"text"},"field_447":{"type":"text"},"field_448":{"type":"text"},"field_449":{"type":"text"},"field_450":{"type":"text"},"field_451":{"type":"text"},"field_452":{"type":"text"},"field_453":{"type":"text"},"field_454":{"type":"text"},"field_455":{"type":"text"},"field_456":{"type":"text"},"field_457":{"type":"text"},"field_458":{"type":"text"},"field_459":{"type":"text"},"field_460":{"type":"text"},"field_461":{"type":"text"},"field_462":{"type":"text"},"field_463":{"type":"text"},"field_464":{"type":"text"},"field_465":{"type":"text"},"field_466":{"type":"text"},"field_467":{"type":"text"},"field_468":{"type":"text"},"field_469":{"type":"text"},"field_470":{"type":"text"},"field_471":{"type":"text"},"field_472":{"type":"text"},"field_473":{"type":"text"},"field_474":{"type":"text"},"field_475":{"type":"text"},"field_476":{"type":"text"},"field_477":{"type":"text"},"field_478":{"type":"text"},"field_479":{"type":"text"},"field_480":{"type":"text"},"field_481":{"type":"text"},"field_482":{"type":"text"},"field_483":{"type":"text"},"field_484":{"type":"text"},"field_485":{"type":"text"},"field_486":{"type":"text"},"field_487":{"type":"text"},"field_488":{"type":"text"},"field_489":{"type":"text"},"field_490":{"type":"text"},"field_491":{"type":"text"},"field_492":{"type":"text"},"field_493":{"type":"text"},"field_494":{"type":"text"},"field_495":{"type":"text"},"field_496":{"type":"text"},"field_497":{"type":"text"},"field_498":{"type":"text"},"field_499":{"type":"text"},"field_500":{"type":"text"},"field_501":{"type":"text"},"field_502":{"type":"text"},"field_503":{"type":"text"},"field_504":{"type":"text"},"field_505":{"type":"text"},"field_506":{"type":"text"},"field_507":{"type":"text"},"field_508":{"type":"text"},"field_509":{"type":"text"},"field_510":{"type":"text"},"field_511":{"type":"text"},"field_512":{"type":"text"},"field_513":{"type":"text"},"field_514":{"type":"text"},"field_515":{"type":"text"},"field_516":{"type":"text"},"field_517":{"type":"text"},"field_518":{"type":"text"},"field_519":{"type":"text"},"field_520":{"type":"text"},"field_521":{"type":"text"},"field_522":{"type":"text"},"field_523":{"type":"text"},"field_524":{"type":"text"},"field_525":{"type":"text"},"field_526":{"type":"text"},"field_527":{"type":"text"},"field_528":{"type":"text"},"field_529":{"type":"text"},"field_530":{"type":"text"},"field_531":{"type":"text"},"field_532":{"type":"text"},"field_533":{"type":"text"},"field_534":{"type":"text"},"field_535":{"type":"text"},"field_536":{"type":"text"},"field_537":{"type":"text"},"field_538":{"type":"text"},"field_539":{"type":"text"},"field_540":{"type":"text"},"field_541":{"type":"text"},"field_542":{"type":"text"},"field_543":{"type":"text"},"field_544":{"type":"text"},"field_545":{"type":"text"},"field_546":{"type":"text"},"field_547":{"type":"text"},"field_548":{"type":"text"},"field_549":{"type":"text"},"field_550":{"type":"text"},"field_551":{"type":"text"},"field_552":{"type":"text"},"field_553":{"type":"text"},"field_554":{"type":"text"},"field_555":{"type":"text"},"field_556":{"type":"text"},"field_557":{"type":"text"},"field_558":{"type":"text"},"field_559":{"type":"text"},"field_560":{"type":"text"},"field_561":{"type":"text"},"field_562":{"type":"text"},"field_563":{"type":"text"},"field_564":{"type":"text"},"field_565":{"type":"text"},"field_566":{"type":"text"},"field_567":{"type":"text"},"field_568":{"type":"text"},"field_569":{"type":"text"},"field_570":{"type":"text"},"field_571":{"type":"text"},"field_572":{"type":"text"},"field_573":{"type":"text"},"field_574":{"type":"text"},"field_575":{"type":"text"},"field_576":{"type":"text"},"field_577":{"type":"text"},"field_578":{"type":"text"},"field_579":{"type":"text"},"field_580":{"type":"text"},"field_581":{"type":"text"},"field_582":{"type":"text"},"field_583":{"type":"text"},"field_584":{"type":"text"},"field_585":{"type":"text"},"field_586":{"type":"text"},"field_587":{"type":"text"},"field_588":{"type":"text"},"field_589":{"type":"text"},"field_590":{"type":"text"},"field_591":{"type":"text"},"field_592":{"type":"text"},"field_593":{"type":"text"},"field_594":{"type":"text"},"field_595":{"type":"text"},"field_596":{"type":"text"},"field_597":{"type":"text"},"field_598":{"type":"text"},"field_599":{"type":"text"},"field_600":{"type":"text"},"field_601":{"type":"text"},"field_602":{"type":"text"},"field_603":{"type":"text"},"field_604":{"type":"text"},"field_605":{"type":"text"},"field_606":{"type":"text"},"field_607":{"type":"text"},"field_608":{"type":"text"},"field_609":{"type":"text"},"field_610":{"type":"text"},"field_611":{"type":"text"},"field_612":{"type":"text"},"field_613":{"type":"text"},"field_614":{"type":"text"},"field_615":{"type":"text"},"field_616":{"type":"text"},"field_617":{"type":"text"},"field_618":{"type":"text"},"field_619":{"type":"text"},"field_620":{"type":"text"},"field_621":{"type":"text"},"field_622":{"type":"text"},"field_623":{"type":"text"},"field_624":{"type":"text"},"field_625":{"type":"text"},"field_626":{"type":"text"},"field_627":{"type":"text"},"field_628":{"type":"text"},"field_629":{"type":"text"},"field_630":{"type":"text"},"field_631":{"type":"text"},"field_632":{"type":"text"},"field_633":{"type":"text"},"field_634":{"type":"text"},"field_635":{"type":"text"},"field_636":{"type":"text"},"field_637":{"type":"text"},"field_638":{"type":"text"},"field_639":{"type":"text"},"field_640":{"type":"text"},"field_641":{"type":"text"},"field_642":{"type":"text"},"field_643":{"type":"text"},"field_644":{"type":"text"},"field_645":{"type":"text"},"field_646":{"type":"text"},"field_647":{"type":"text"},"field_648":{"type":"text"},"field_649":{"type":"text"},"field_650":{"type":"text"},"field_651":{"type":"text"},"field_652":{"type":"text"},"field_653":{"type":"text"},"field_654":{"type":"text"},"field_655":{"type":"text"},"field_656":{"type":"text"},"field_657":{"type":"text"},"field_658":{"type":"text"},"field_659":{"type":"text"},"field_660":{"type":"text"},"field_661":{"type":"text"},"field_662":{"type":"text"},"field_663":{"type":"text"},"field_664":{"type":"text"},"field_665":{"type":"text"},"field_666":{"type":"text"},"field_667":{"type":"text"},"field_668":{"type":"text"},"field_669":{"type":"text"},"field_670":{"type":"text"},"field_671":{"type":"text"},"field_672":{"type":"text"},"field_673":{"type":"text"},"field_674":{"type":"text"},"field_675":{"type":"text"},"field_676":{"type":"text"},"field_677":{"type":"text"},"field_678":{"type":"text"},"field_679":{"type":"text"},"field_680":{"type":"text"},"field_681":{"type":"text"},"field_682":{"type":"text"},"field_683":{"type":"text"},"field_684":{"type":"text"},"field_685":{"type":"text"},"field_686":{"type":"text"},"field_687":{"type":"text"},"field_688":{"type":"text"},"field_689":{"type":"text"},"field_690":{"type":"text"},"field_691":{"type":"text"},"field_692":{"type":"text"},"field_693":{"type":"text"},"field_694":{"type":"text"},"field_695":{"type":"text"},"field_696":{"type":"text"},"field_697":{"type":"text"},"field_698":{"type":"text"},"field_699":{"type":"text"},"field_700":{"type":"text"},"field_701":{"type":"text"},"field_702":{"type":"text"},"field_703":{"type":"text"},"field_704":{"type":"text"},"field_705":{"type":"text"},"field_706":{"type":"text"},"field_707":{"type":"text"},"field_708":{"type":"text"},"field_709":{"type":"text"},"field_710":{"type":"text"},"field_711":{"type":"text"},"field_712":{"type":"text"},"field_713":{"type":"text"},"field_714":{"type":"text"},"field_715":{"type":"text"},"field_716":{"type":"text"},"field_717":{"type":"text"},"field_718":{"type":"text"},"field_719":{"type":"text"},"field_720":{"type":"text"},"field_721":{"type":"text"},"field_722":{"type":"text"},"field_723":{"type":"text"},"field_724":{"type":"text"},"field_725":{"type":"text"},"field_726":{"type":"text"},"field_727":{"type":"text"},"field_728":{"type":"text"},"field_729":{"type":"text"},"field_730":{"type":"text"},"field_731":{"type":"text"},"field_732":{"type":"text"},"field_733":{"type":"text"},"field_734":{"type":"text"},"field_735":{"type":"text"},"field_736":{"type":"text"},"field_737":{"type":"text"},"field_738":{"type":"text"},"field_739":{"type":"text"},"field_740":{"type":"text"},"field_741":{"type":"text"},"field_742":{"type":"text"},"field_743":{"type":"text"},"field_744":{"type":"text"},"field_745":{"type":"text"},"field_746":{"type":"text"},"field_747":{"type":"text"},"field_748":{"type":"text"},"field_749":{"type":"text"},"field_750":{"type":"text"},"field_751":{"type":"text"},"field_752":{"type":"text"},"field_753":{"type":"text"},"field_754":{"type":"text"},"field_755":{"type":"text"},"field_756":{"type":"text"},"field_757":{"type":"text"},"field_758":{"type":"text"},"field_759":{"type":"text"},"field_760":{"type":"text"},"field_761":{"type":"text"},"field_762":{"type":"text"},"field_763":{"type":"text"},"field_764":{"type":"text"},"field_765":{"type":"text"},"field_766":{"type":"text"},"field_767":{"type":"text"},"field_768":{"type":"text"},"field_769":{"type":"text"},"field_770":{"type":"text"},"field_771":{"type":"text"},"field_772":{"type":"text"},"field_773":{"type":"text"},"field_774":{"type":"text"},"field_775":{"type":"text"},"field_776":{"type":"text"},"field_777":{"type":"text"},"field_778":{"type":"text"},"field_779":{"type":"text"},"field_780":{"type":"text"},"field_781":{"type":"text"},"field_782":{"type":"text"},"field_783":{"type":"text"},"field_784":{"type":"text"},"field_785":{"type":"text"},"field_786":{"type":"text"},"field_787":{"type":"text"},"field_788":{"type":"text"},"field_789":{"type":"text"},"field_790":{"type":"text"},"field_791":{"type":"text"},"field_792":{"type":"text"},"field_793":{"type":"text"},"field_794":{"type":"text"},"field_795":{"type":"text"},"field_796":{"type":"text"},"field_797":{"type":"text"},"field_798":{"type":"text"},"field_799":{"type":"text"},"field_800":{"type":"text"},"field_801":{"type":"text"},"field_802":{"type":"text"},"field_803":{"type":"text"},"field_804":{"type":"text"},"field_805":{"type":"text"},"field_806":{"type":"text"},"field_807":{"type":"text"},"field_808":{"type":"text"},"field_809":{"type":"text"},"field_810":{"type":"text"},"field_811":{"type":"text"},"field_812":{"type":"text"},"field_813":{"type":"text"},"field_814":{"type":"text"},"field_815":{"type":"text"},"field_816":{"type":"text"},"field_817":{"type":"text"},"field_818":{"type":"text"},"field_819":{"type":"text"},"field_820":{"type":"text"},"field_821":{"type":"text"},"field_822":{"type":"text"},"field_823":{"type":"text"},"field_824":{"type":"text"},"field_825":{"type":"text"},"field_826":{"type":"text"},"field_827":{"type":"text"},"field_828":{"type":"text"},"field_829":{"type":"text"},"field_830":{"type":"text"},"field_831":{"type":"text"},"field_832":{"type":"text"},"field_833":{"type":"text"},"field_834":{"type":"text"},"field_835":{"type":"text"},"field_836":{"type":"text"},"field_837":{"type":"text"},"field_838":{"type":"text"},"field_839":{"type":"text"},"field_840":{"type":"text"},"field_841":{"type":"text"},"field_842":{"type":"text"},"field_843":{"type":"text"},"field_844":{"type":"text"},"field_845":{"type":"text"},"field_846":{"type":"text"},"field_847":{"type":"text"},"field_848":{"type":"text"},"field_849":{"type":"text"},"field_850":{"type":"text"},"field_851":{"type":"text"},"field_852":{"type":"text"},"field_853":{"type":"text"},"field_854":{"type":"text"},"field_855":{"type":"text"},"field_856":{"type":"text"},"field_857":{"type":"text"},"field_858":{"type":"text"},"field_859":{"type":"text"},"field_860":{"type":"text"},"field_861":{"type":"text"},"field_862":{"type":"text"},"field_863":{"type":"text"},"field_864":{"type":"text"},"field_865":{"type":"text"},"field_866":{"type":"text"},"field_867":{"type":"text"},"field_868":{"type":"text"},"field_869":{"type":"text"},"field_870":{"type":"text"},"field_871":{"type":"text"},"field_872":{"type":"text"},"field_873":{"type":"text"},"field_874":{"type":"text"},"field_875":{"type":"text"},"field_876":{"type":"text"},"field_877":{"type":"text"},"field_878":{"type":"text"},"field_879":{"type":"text"},"field_880":{"type":"text"},"field_881":{"type":"text"},"field_882":{"type":"text"},"field_883":{"type":"text"},"field_884":{"type":"text"},"field_885":{"type":"text"},"field_886":{"type":"text"},"field_887":{"type":"text"},"field_888":{"type":"text"},"field_889":{"type":"text"},"field_890":{"type":"text"},"field_891":{"type":"text"},"field_892":{"type":"text"},"field_893":{"type":"text"},"field_894":{"type":"text"},"field_895":{"type":"text"},"field_896":{"type":"text"},"field_897":{"type":"text"},"field_898":{"type":"text"},"field_899":{"type":"text"},"field_900":{"type":"text"},"field_901":{"type":"text"},"field_902":{"type":"text"},"field_903":{"type":"text"},"field_904":{"type":"text"},"field_905":{"type":"text"},"field_906":{"type":"text"},"field_907":{"type":"text"},"field_908":{"type":"text"},"field_909":{"type":"text"},"field_910":{"type":"text"},"field_911":{"type":"text"},"field_912":{"type":"text"},"field_913":{"type":"text"},"field_914":{"type":"text"},"field_915":{"type":"text"},"field_916":{"type":"text"},"field_917":{"type":"text"},"field_918":{"type":"text"},"field_919":{"type":"text"},"field_920":{"type":"text"},"field_921":{"type":"text"},"field_922":{"type":"text"},"field_923":{"type":"text"},"field_924":{"type":"text"},"field_925":{"type":"text"},"field_926":{"type":"text"},"field_927":{"type":"text"},"field_928":{"type":"text"},"field_929":{"type":"text"},"field_930":{"type":"text"},"field_931":{"type":"text"},"field_932":{"type":"text"},"field_933":{"type":"text"},"field_934":{"type":"text"},"field_935":{"type":"text"},"field_936":{"type":"text"},"field_937":{"type":"text"},"field_938":{"type":"text"},"field_939":{"type":"text"},"field_940":{"type":"text"},"field_941":{"type":"text"},"field_942":{"type":"text"},"field_943":{"type":"text"},"field_944":{"type":"text"},"field_945":{"type":"text"},"field_946":{"type":"text"},"field_947":{"type":"text"},"field_948":{"type":"text"},"field_949":{"type":"text"},"field_950":{"type":"text"},"field_951":{"type":"text"},"field_952":{"type":"text"},"field_953":{"type":"text"},"field_954":{"type":"text"},"field_955":{"type":"text"},"field_956":{"type":"text"},"field_957":{"type":"text"},"field_958":{"type":"text"},"field_959":{"type":"text"},"field_960":{"type":"text"},"field_961":{"type":"text"},"field_962":{"type":"text"},"field_963":{"type":"text"},"field_964":{"type":"text"},"field_965":{"type":"text"},"field_966":{"type":"text"},"field_967":{"type":"text"},"field_968":{"type":"text"},"field_969":{"type":"text"},"field_970":{"type":"text"},"field_971":{"type":"text"},"field_972":{"type":"text"},"field_973":{"type":"text"},"field_974":{"type":"text"},"field_975":{"type":"text"},"field_976":{"type":"text"},"field_977":{"type":"text"},"field_978":{"type":"text"},"field_979":{"type":"text"},"field_980":{"type":"text"},"field_981":{"type":"text"},"field_982":{"type":"text"},"field_983":{"type":"text"},"field_984":{"type":"text"},"field_985":{"type":"text"},"field_986":{"type":"text"},"field_987":{"type":"text"},"field_988":{"type":"text"},"field_989":{"type":"text"},"field_990":{"type":"text"},"field_991":{"type":"text"},"field_992":{"type":"text"},"field_993":{"type":"text"},"field_994":{"type":"text"},"field_995":{"type":"text"},"field_996":{"type":"text"},"field_997":{"type":"text"},"field_998":{"type":"text"},"field_999":{"type":"text"}}}}

# Insert sparse document
PUT my-index/_doc/1
{
  "field_086": "The quick brown fox",
  "field_498": "jumps over the lazy dog"
}

# Query all fields and highlight
GET my-index/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "simple_query_string": {
            "query": "brown fox"
          }
        }
      ]
    }
  },
  "highlight": {
    "fields": {
      "field_*": {
        "type": "unified"
      }
    }
  }
}

With 7.17 this query takes 1399ms.
With 6.8 it takes 19ms.
With 8.0.1 it takes 18ms.

As mentionned in Highlighters are slow with thousands of fields · Issue #36452 · elastic/elasticsearch · GitHub and Bypass highlight query terms extraction on empty fields by jimczi · Pull Request #32090 · elastic/elasticsearch · GitHub there should now be a shortcut to bypass empty fields. From those numbers it looks like maybe the shortcut stopped working in 7?

Unfortunately we are currently unable to upgrade to 8 since there is no .NET client for it yet so we are stuck with 6.8 which is EOL.

Elasticsearch 6.8 is EOL and no longer supported. Please upgrade ASAP.

(This is an automated response from your friendly Elastic bot. Please report this post if you have any suggestions or concerns :elasticheart: )

Dear bot, please read the title of this post, we are trying to upgrade!

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.