run-llama / llama_index

LlamaIndex is a data framework for your LLM applications
https://docs.llamaindex.ai
MIT License
33.45k stars 4.69k forks source link

[Documentation]: retrieval_strategy=AsyncDenseVectorStrategy(hybrid=True) #14185

Open yw1991 opened 3 weeks ago

yw1991 commented 3 weeks ago

Documentation Issue Description

elasticsearch.BadRequestError: BadRequestError(400, 'parsing_exception', 'Unknown key for a START_OBJECT in [rank].'

Documentation Link

*

dosubot[bot] commented 3 weeks ago

@yw1991 Hello there! I'm a bot here to help you with any bugs, questions, or contributions while you wait for a human maintainer.

The error elasticsearch.BadRequestError: BadRequestError(400, 'parsing_exception', 'Unknown key for a START_OBJECT in [rank].' suggests an issue with the way the rank field is being handled in the Elasticsearch query. This is likely related to the hybrid mode in the AsyncDenseVectorStrategy.

To resolve this issue, ensure that the rank field is correctly mapped and recognized by Elasticsearch. Here is a potential fix:

  1. Ensure the rank field is correctly mapped in your Elasticsearch index.
  2. Modify the code to handle the rank field properly.

Check and potentially modify the following code snippet:

top_k_nodes = []
top_k_ids = []
top_k_scores = []
for hit in hits:
    source = hit["_source"]
    metadata = source.get("metadata", None)
    text = source.get(self.text_field, None)
    node_id = hit["_id"]

    try:
        node = metadata_dict_to_node(metadata)
        node.text = text
    except Exception:
        # Legacy support for old metadata format
        logger.warning(
            f"Could not parse metadata from hit {hit['_source']['metadata']}"
        )
        node_info = source.get("node_info")
        relationships = source.get("relationships", {})
        start_char_idx = None
        end_char_idx = None
        if isinstance(node_info, dict):
            start_char_idx = node_info.get("start", None)
            end_char_idx = node_info.get("end", None)

        node = TextNode(
            text=text,
            metadata=metadata,
            id_=node_id,
            start_char_idx=start_char_idx,
            end_char_idx=end_char_idx,
            relationships=relationships,
        )
    top_k_nodes.append(node)
    top_k_ids.append(node_id)
    top_k_scores.append(hit.get("_rank", hit["_score"]))

if (
    isinstance(self.retrieval_strategy, AsyncDenseVectorStrategy)
    and self.retrieval_strategy.hybrid
):
    total_rank = sum(top_k_scores)
    top_k_scores = [total_rank - rank / total_rank for rank in top_k_scores]

return VectorStoreQueryResult(
    nodes=top_k_nodes,
    ids=top_k_ids,
    similarities=_to_llama_similarities(top_k_scores),
)

Ensure the _rank field is correctly mapped and recognized by Elasticsearch. If _rank is not valid, use a different field or adjust the score calculations.

Additionally, ensure the mode matches the retrieval strategy. For AsyncDenseVectorStrategy(hybrid=True), the mode should be VectorStoreQueryMode.HYBRID. Here is a test case to ensure the mode matches the retrieval strategy:

def test_mode_must_match_retrieval_strategy() -> None:
    # DEFAULT mode should never raise any exception
    mode = VectorStoreQueryMode.DEFAULT
    retrieval_strategy = AsyncBM25Strategy()
    _mode_must_match_retrieval_strategy(mode, retrieval_strategy)

    # AsyncSparseVectorStrategy with mode SPARSE should not raise any exception
    mode = VectorStoreQueryMode.SPARSE
    retrieval_strategy = AsyncSparseVectorStrategy()
    _mode_must_match_retrieval_strategy(mode, retrieval_strategy)

    # AsyncBM25Strategy with TEXT_SEARCH should not raise any exception
    mode = VectorStoreQueryMode.TEXT_SEARCH
    retrieval_strategy = AsyncBM25Strategy()
    _mode_must_match_retrieval_strategy(mode, retrieval_strategy)

    # AsyncDenseVectorStrategy(hybrid=True) with mode HYBRID should not raise any exception
    mode = VectorStoreQueryMode.HYBRID
    retrieval_strategy = AsyncDenseVectorStrategy(hybrid=True)
    _mode_must_match_retrieval_strategy(mode, retrieval_strategy)

    # unknown mode should raise NotImplementedError
    for mode in [
        VectorStoreQueryMode.SEMANTIC_HYBRID,
        VectorStoreQueryMode.SVM,
        VectorStoreQueryMode.LOGISTIC_REGRESSION,
        VectorStoreQueryMode.LINEAR_REGRESSION,
        VectorStoreQueryMode.MMR,
    ]:
        retrieval_strategy = AsyncDenseVectorStrategy()
        with pytest.raises(NotImplementedError):
            _mode_must_match_retrieval_strategy(mode, retrieval_strategy)

    # if mode is SPARSE and strategy is not AsyncSparseVectorStrategy, should raise ValueError
    mode = VectorStoreQueryMode.SPARSE
    retrieval_strategy = AsyncDenseVectorStrategy()
    with pytest.raises(ValueError):
        _mode_must_match_retrieval_strategy(mode, retrieval_strategy)

    # if mode is HYBRID and strategy is not AsyncDenseVectorStrategy, should raise ValueError
    mode = VectorStoreQueryMode.HYBRID
    retrieval_strategy = AsyncSparseVectorStrategy()
    with pytest.raises(ValueError):
        _mode_must_match_retrieval_strategy(mode, retrieval_strategy)

    # if mode is HYBRID and strategy is AsyncDenseVectorStrategy but hybrid is not enabled, should raise ValueError
    mode = VectorStoreQueryMode.HYBRID
    retrieval_strategy = AsyncDenseVectorStrategy(hybrid=False)
    with pytest.raises(ValueError):
        _mode_must_match_retrieval_strategy(mode, retrieval_strategy)

Ensure your mode and retrieval strategy are correctly aligned to avoid such errors [1][2].

To continue talking to Dosu, mention @dosu.

yw1991 commented 3 weeks ago

@Dosu first,thanks for your reply。here is some more details。 {'knn': {'filter': [], 'field': 'embedding', 'k': 2, 'num_candidates': 20, 'query_vector': [0.020329274237155914, -0.016439935192465782, -0.01222333125770092, 0.020656481385231018, 0.015827272087335587, -0.00888893287628889, -0.01562308706343174, -0.03606059402227402, 0.04976935684680939, 0.029119601473212242, -0.002741447649896145, -0.016362575814127922, 0.0332820825278759, -0.019691595807671547, 0.012075891718268394, 0.0025564960669726133, -0.007536637596786022, 0.0033704356756061316, -0.02809642255306244, -0.02092575468122959, -0.005240238271653652, 0.025649499148130417, -0.004175655543804169, 0.025530824437737465, -0.0008253990672528744, -0.026714101433753967, 0.051027391105890274, 0.010184605605900288, 0.051661282777786255, -0.01330967340618372, -0.015519294887781143, 0.010468732565641403, -0.01525014080107212, 0.038076017051935196, 0.006049429532140493, 0.006912425626069307, -0.023785796016454697, 0.007381633389741182, 0.004440117161720991, -0.03070686198771, 0.019244011491537094, -0.003923557233065367, 0.02523256465792656, -0.06550795584917068, 0.001166821108199656, -0.017986014485359192, -0.017642419785261154, -0.027649110183119774, 0.007086060009896755, 0.0020284736528992653, 0.04732909053564072, -0.006779277231544256, -0.009489464573562145, 0.00970165804028511, -0.031571876257658005, 0.026365911588072777, 0.020602503791451454, 0.02348574995994568, -0.02765243500471115, -0.002478653797879815, -0.014957155101001263, 0.27513399720191956, 0.010376036167144775, 0.005817563738673925, -0.013377231545746326, 0.004174213390797377, 0.010696403682231903, 0.014416281133890152, -0.009168765507638454, -0.002566420705989003, 0.007733335718512535, -0.00025632293545641005, -0.003997491672635078, 0.024766208603978157, -0.00036237502354197204, 0.0059305704198777676, -0.00940575823187828, -0.014234567061066628, -0.009633033536374569, -0.013498012907803059, -0.011609544046223164, 0.007368254009634256, 0.030240189284086227, 0.003081308677792549, 0.017680330201983452, -0.016053877770900726, 0.03443997725844383, 0.6659529209136963, -0.0002952819922938943, 0.02241729013621807, 0.0077985720708966255, 0.018071888014674187, -0.023785114288330078, 0.0029143409337848425, -0.000205653443117626, -0.020456597208976746, 0.02079182118177414, -0.019969657063484192, -0.04976644366979599, -0.011992249637842178, 0.009986929595470428, 0.0076965647749602795, -0.03454209864139557, -0.017101813107728958, -0.021121185272932053, 0.014509577304124832, -0.021011877804994583, -0.0534089058637619, -0.009728622622787952, -0.030866747722029686, 0.028964322060346603, -0.01541442982852459, 0.0038019856438040733, -0.003983025439083576, -0.009112345054745674, 0.006359950173646212, 0.025645220652222633, 0.008345494978129864, 0.010245728306472301, 0.01649991050362587, 0.005208227783441544, 0.03587633743882179, -0.000737388210836798, -0.012415791861712933, 0.009661521762609482, 0.00028090932755731046, -0.005159290973097086, -0.008946229703724384, 0.011386929079890251, -0.013389317318797112, 0.017617151141166687, -0.014854146167635918, -0.001170898205600679, -0.005153430160135031, -0.009071567095816135, 0.02032872848212719, -0.01863989047706127, 0.008945468813180923, -0.0043152268044650555, -0.0005871430039405823, 0.03297213092446327, 0.001977963373064995, 0.0032101545948535204, -0.01854153722524643, 0.012299290858209133, -0.03360489010810852, -0.022069571539759636, 0.010739424265921116, 0.029817605391144753, -0.039313431829214096, 0.0015716489870101213, -0.02724459022283554, -0.023984072729945183, -0.040527909994125366, 0.0017336778109893203, -0.03894423693418503, 0.031406790018081665, 0.018498536199331284, 0.01690034009516239, -0.03053436428308487, 0.039694417268037796, 0.005342721473425627, 0.01161812525242567, 0.008850904181599617, -0.01020386628806591, 0.01215854100883007, 0.028949793428182602, -0.03002856858074665, 0.015785977244377136, 0.028102748095989227, -0.029611382633447647, 0.010397706180810928, 0.01067579910159111, 0.005819510202854872, 0.04110105335712433, -0.016545835882425308, 0.009348755702376366, 0.01860138773918152, 0.007365602068603039, 0.02483563870191574, 0.020235056057572365, 0.003951475024223328, 0.009940322488546371, -0.0042501045390963554, 0.0029419013299047947, 0.01893536187708378, 0.011640414595603943, -0.004167667590081692, -0.0018101197201758623, -0.03143971413373947, -0.017755940556526184, 0.021819330751895905, 0.029070472344756126, -0.04157961532473564, -0.015886230394244194, 0.013954048976302147, -0.0205618217587471, -0.01799621433019638, -0.006565671879798174, 0.000844244787003845, -0.02651955559849739, 0.016671115532517433, 0.003044463461264968, 0.02419034205377102, -0.007172714918851852, -0.02365092933177948, 0.013321282342076302, -0.00031893476261757314, 0.01822861097753048, 0.01686474122107029, -0.023543577641248703, -0.013733340427279472, 0.015345628373324871, 0.009825075976550579, -0.018069317564368248, -0.008895505219697952, -0.01804587058722973, -0.0041801417246460915, -0.01463606208562851, 0.01798340119421482, 0.0321781262755394, 0.009479745291173458, -0.011207050643861294, -0.018505094572901726, 0.019428031519055367, 0.004878494888544083, 0.0106356767937541, -0.02007715404033661, -0.02374391071498394, 0.008739382028579712, -0.024257132783532143, -0.012258431874215603, 0.023806722834706306, 0.0004211648483760655, -0.008512684144079685, -0.016982199624180794, 0.033339206129312515, -0.007792821153998375, -0.012508629821240902, 0.0011069371830672026, -0.017382115125656128, 0.008313643746078014, -0.004383585415780544, -0.03436248376965523, 0.0161832794547081, 0.004520326387137175, 0.014193883165717125, 0.02064836211502552, -0.014104579575359821, 0.005332938861101866, -0.0020291698165237904, -0.011023356579244137, 0.014824512414634228, -0.0521913506090641, 0.013545972295105457, -0.03431107848882675, -0.008948776870965958, 0.003895512316375971, 0.021302346140146255, 0.031358808279037476, 0.015384136699140072, 0.03233204782009125, -0.004017835948616266, -0.024872051551938057, -0.0056441486813127995, 0.008926626294851303, -0.0019570414442569017, 0.014668607152998447, -0.03666550666093826, 0.0015574299031868577, -0.011572553776204586, 0.027623092755675316, -0.022177448496222496, -0.03144596144556999, -0.020538663491606712, 0.004835388157516718, -0.0393996424973011, 0.012932831421494484, -0.010303341783583164, -0.009311350993812084, -0.021142536774277687, 0.008296611718833447, -0.029575901105999947, 0.0037163021042943, 0.012439648620784283, -0.0007158619118854403, -0.05201083794236183, -0.04657416045665741, 0.003529742592945695, -0.01051840279251337, -0.009037808515131474, 0.000571705459151417, 0.006366264540702105, -0.024444935843348503, -0.023829685524106026, 0.014127403497695923, 0.0015527429059147835, -0.018077656626701355, -0.039448488503694534, -0.018418220803141594, 0.04883118346333504, 0.005317091941833496, 0.004002789966762066, -0.015887761488556862, -0.002041307045146823, 0.054332684725522995, -0.0244329571723938, -0.030067533254623413, -0.006075720302760601, 0.0030039798002690077, -0.0017253872938454151, -0.026314137503504753, -0.00039545082836411893, -0.005224898923188448, 0.03044009394943714, -0.031966619193553925, 0.010867491364479065, -0.016902830451726913, -0.01546237152069807, 0.0362623892724514, 0.02198990434408188, 0.009067664854228497, -0.034472592175006866, -0.07338064163923264, 0.038962285965681076, 0.027712740004062653, 0.023937562480568886, 0.006155680865049362, 0.0005546078318729997, -0.04579202085733414, 0.015370846726000309, 0.022660881280899048, -0.042426448315382004, -0.019776029512286186, -0.00966611783951521, 0.02660316415131092, 0.04917048662900925, -0.032164834439754486, 0.009201363660395145, 0.0347210168838501, 0.010690328665077686, 0.012093733996152878, -0.05096052587032318, -0.035812363028526306, 0.022168433293700218, -0.030898461118340492, -0.0040168254636228085, 0.018580403178930283, -0.02248539961874485, -0.03651352971792221, 0.013269889168441296, 0.04591579735279083, 0.016993509605526924, 0.00690371124073863, 0.005806173197925091, -0.01064919400960207, -0.0038694667164236307, 0.03416285291314125, -0.008616657927632332, 0.022026756778359413, -0.006150258705019951, -0.0007132046739570796, 0.004886947106570005, 0.02638288587331772, -0.016298003494739532, -0.011570816859602928, -0.006847335025668144, 0.00901087187230587, -0.020307136699557304, -0.010206172242760658, 0.033569224178791046, 0.018402788788080215, -0.020970195531845093, -0.014239760115742683, 0.0175724308937788, -0.022900812327861786, -0.0089228805154562, -0.021260831505060196, 0.03815494850277901, -0.009230476804077625, 0.012139134109020233, -0.010677319020032883, -0.00732805859297514, 0.0350688211619854, 0.024879297241568565, 0.033575549721717834, 0.014400636777281761, 0.007072698790580034, 0.013797230087220669, 0.00478056725114584, -0.009797431528568268, -0.005149355623871088, -0.04033823683857918, -0.01187916286289692, -0.02645828016102314, 0.03256018087267876, -0.002465503290295601, -0.007854239083826542, -0.010562233626842499, 0.007620376069098711, -0.008107823319733143, -0.019966943189501762, 0.006333576049655676, -0.1342935562133789, 0.02927028387784958, -0.011625334620475769, -0.009571554139256477, 0.013790037482976913, -0.021339211612939835, 0.023925011977553368, -0.02933369390666485, 0.0025509207043796778, -0.07191973179578781, -0.031376179307699203, -0.034489501267671585, -0.008682439103722572, -0.002208106918260455, 0.041817549616098404, -0.013270030729472637, -0.007437358144670725, 0.03145001083612442, -0.01687736064195633, 0.010530364699661732, -0.016022711992263794, 0.005736944731324911, 0.0171678327023983, -0.04286668449640274, 0.018382489681243896, 0.0022097714245319366, 0.0014407547423616052, -0.0329243466258049, -0.010471302084624767, -0.03299896791577339, 0.014155682176351547, 0.015941482037305832, -0.028629127889871597, 0.006179311778396368, -0.03968260809779167, 0.001327392878010869, -0.00279997568577528, 0.0006855434039607644, -0.02176639623939991, 0.012086117640137672, -0.03517858684062958, -0.0018250850262120366, -0.014123656786978245, 0.0002612521930132061, -0.013909080065786839, 0.007602175232023001, -0.04911847412586212, 0.004300924949347973, -0.023528721183538437, 0.014896787703037262, 0.016189493238925934, -0.002988299122080207, -0.009827226400375366, -0.00417307298630476, 0.011283676140010357, 0.007466015871614218, -0.024152645841240883, -0.009358239360153675, 0.02735491469502449, -0.02187461033463478, 0.02657320536673069, -0.027786679565906525, -0.02508155070245266, -0.019551560282707214, 0.009725627489387989, 0.017585476860404015, 0.0022093483712524176, -0.008448010310530663, -0.012197484262287617, 0.00859589409083128, -0.011658251285552979, 0.010555160231888294, 0.014776385389268398, -0.009967050515115261, 0.018198492005467415, -0.026397185400128365, 0.03562456741929054, -0.018801210448145866, -0.008104543201625347, -0.048099335283041, 0.021824300289154053, 0.018837716430425644, -0.01710759848356247, -0.01756059192121029, 0.01159463357180357, -0.030286062508821487, -0.0006723921396769583, -0.04806223139166832, 0.013510530814528465, -0.009515432640910149, 0.005481475964188576, -0.0249042846262455, -0.01580582931637764, 0.02791176550090313, 0.01921810954809189, 0.009755619801580906, -0.019341038540005684, -0.019630813971161842, -0.019168855622410774, -0.03831850364804268, 0.027292262762784958, -0.00720051908865571, 0.024718081578612328, -0.008728409186005592, -0.03806265443563461, -0.00926473829895258, 0.004736367147415876, -0.0008345728274434805, 0.0038411105051636696, 0.028850020840764046, 0.005428892560303211, 0.00910916831344366, -0.01684805192053318, 0.01672920398414135, 0.024667363613843918, -0.0006359902326948941, -0.017867039889097214, 0.0077500189654529095, 0.0031002149917185307, 0.03235488757491112, 0.003914398606866598, -0.004858652129769325, -0.027415979653596878, -0.016636723652482033, 0.011013113893568516, -0.0029498375952243805, -0.034776654094457626, -0.037613049149513245, -0.041898276656866074, 0.009941652417182922, -0.01659316010773182, 0.00984152127057314, 0.0023569155018776655, 0.009161736816167831, 0.02155500277876854, -0.0031186474952846766, 0.02683764509856701, 0.01101846806704998, 0.0068071987479925156, 0.003912264481186867, 0.005524065345525742, -0.008756838738918304, 0.01503097452223301, 0.0020225520711392164, 0.01880066841840744, 0.021642830222845078, 0.026836372911930084, -0.02075633965432644, 0.00028527897666208446, -0.030346371233463287, -0.03533744066953659, -0.0373358279466629, -0.04584389925003052, -0.006260963622480631, -0.008355786092579365, 0.020376358181238174, 0.0017569337505847216, -0.008232288993895054, -0.015774067491292953, 0.010249166749417782, 0.01886669546365738, 0.014631567522883415, -0.00880317110568285, 0.022338781505823135, 0.013272758573293686, 0.0034614175092428923, -0.0395328588783741, -0.02509121038019657, -0.001761330640874803, -0.047880712896585464, -0.022506657987833023, -0.007654463406652212, 0.06132205203175545, -0.008331868797540665, 0.003134667407721281, 0.0024117904249578714, 0.018848972395062447, -0.001206110930070281, -0.0018593614222481847, -0.010998924262821674, -0.0013794887345284224, -0.02616899274289608, -0.0011688509257510304, 0.012386558577418327, 0.00686897337436676, -0.008076729252934456, 0.008497052825987339, 0.028129391372203827, -0.006633989047259092, -0.04341231659054756, 0.027155548334121704, 0.011904699727892876, -0.007305399049073458, -0.008541255258023739, 0.011588973924517632, -0.007645767647773027, -0.014721745625138283, -0.05574188008904457, -0.0027861727867275476, -0.013535529375076294, -0.03499249741435051, 0.01837226189672947, 0.013408689759671688, -0.007865174673497677, 0.006330741103738546, -0.00783281959593296, -0.011649245396256447, -0.0006457164417952299, 0.0017448196886107326, -0.013493215665221214, 0.015805497765541077, -0.02145242504775524, -0.024817731231451035, 0.01089349016547203, 0.01904367096722126, -0.05570928752422333, 0.006269506644457579, 0.02346196211874485, 0.019373657181859016, -0.024240069091320038, -0.050728898495435715, -0.0010151639580726624, 0.001703324494883418, -0.025667227804660797, -0.0028744377195835114, -0.006400208920240402, -0.005095819942653179, -0.017006082460284233, 0.02734469249844551, -0.02165001817047596, -0.0072893789038062096, -0.0015216286992654204, -0.07711320370435715, -0.0007343313191086054, 0.021044952794909477, -0.0015376410447061062, 0.016803033649921417, -0.0028317212127149105, -0.05162898451089859, 0.006603400222957134, 0.008256589993834496, -0.02653932385146618, 0.0081639364361763, -0.02673831582069397, -0.022980187088251114, -0.0004034498706459999, 0.005925668869167566, -0.012774168513715267, 0.007664060685783625, 0.010211578570306301, 0.03920520097017288, -0.009830509312450886, -0.00893803033977747, -0.009052480570971966, 0.011409911327064037, -0.02841068245470524, 0.03220711648464203, -0.0020849001593887806, -0.0024089831858873367, -0.0009105656063184142, 0.010445158928632736, -0.006055851466953754, 0.024836624041199684, 0.01645667664706707, -0.004230189602822065, 0.024851135909557343, 0.022051852196455002, 0.0068313260562717915, -0.03592973202466965, 0.008599556051194668, 0.03735915571451187, -0.005237695295363665, 0.010038292966783047, 0.027964692562818527, 0.028253423050045967, -0.02249079942703247, -0.007942561991512775, 0.01562955416738987, -0.01750418171286583, 0.025304602459073067, 0.037508051842451096, -0.0025928241666406393, -0.024952754378318787, 0.03623266518115997, 0.017183294519782066, 0.01016431488096714, 0.021677786484360695, -0.00450546108186245, -0.004868964198976755, 0.043896403163671494, -0.00011864519910886884, -0.004084986634552479, -0.022039031609892845, 0.024064011871814728, 0.004435551352798939, -0.02067112736403942, 0.005009624641388655, -0.02224859595298767, 0.011571034789085388, -0.020215924829244614, 0.010267678648233414, 0.05710897222161293, -0.0017218783032149076, 0.005481444299221039, 0.02433018386363983, -0.003383791306987405, 0.010792294517159462, -0.03192638233304024, 0.00865211058408022, -0.002191827865317464, -0.017436062917113304, -0.020095404237508774, -0.01727747730910778, -0.05177682638168335, 0.018742388114333153, -0.020314835011959076, 0.029498327523469925, -0.012917209416627884, -0.018299899995326996, -0.03686997666954994, 0.02493378147482872, 0.017895907163619995, -0.03306683897972107, 0.016487527638673782, -0.01361153181642294, -0.005893855821341276, 0.014464888721704483, 0.027510179206728935, 0.003573059570044279, 0.025288637727499008, -0.02816781960427761, 0.021855581551790237, -0.008557474240660667, -0.002409878885373473, -0.0401870459318161, -0.001571736647747457, -0.04547818750143051, 0.019199177622795105, 0.039922188967466354, 0.008248433470726013, -0.003712270176038146, -0.03927169367671013, -4.497188638197258e-05, 0.029873089864850044, 0.022699732333421707, -0.0027053747326135635, 0.04011036455631256, -0.010420266538858414, -0.010751904919743538, -0.022610004991292953, -0.05052505433559418, 0.01076511200517416, -0.016659120097756386, -0.01261586882174015, 0.011236575432121754, -0.004690405912697315, 0.006709616631269455, -0.009331933222711086, -0.043199244886636734, 0.012552549131214619, -0.03455517813563347, -0.001718871179036796, -0.016625631600618362, -0.04975235462188721, -0.03235096484422684, -0.014262779615819454, 0.029884804040193558, -0.007568842731416225, -0.004406892694532871, -0.04823032021522522, -0.013598315417766571, -0.024471089243888855, -0.020558906719088554, 0.010603569447994232, 0.023372141644358635, -0.010912232100963593, 0.011828876100480556, -0.038960568606853485, -0.009555328637361526, 0.012487503699958324, -0.040108151733875275, -0.011087768711149693, -0.0025596641935408115, 0.019487231969833374, 0.006687019020318985, 0.02927706018090248, 0.0048258621245622635, -0.02040741592645645, 0.010556729510426521, 0.03477206081151962, -0.03400406613945961, 0.0032317268196493387, 0.020664196461439133, -0.0008693226845934987, 0.004225793294608593, 0.0010619022650644183, 0.001440138090401888, -0.016150424256920815, 0.002137611387297511, -0.003367447294294834, -0.050760362297296524, -0.03449574485421181, -0.00615606689825654, -0.018948933109641075, -0.011600587517023087, -0.045044105499982834, -0.01015603356063366, 0.003442200133576989, -0.026369037106633186, 0.04207709804177284, -0.015131172724068165, 0.037722356617450714, -0.016382314264774323, -0.0018265454564243555, -0.03457094728946686, 0.024485433474183083, -0.024028334766626358, 0.01292336080223322, -0.014606437645852566, -0.04261980205774307, 0.0006601304630748928, 0.009222227148711681, 0.006228054873645306, -0.0030291308648884296, 0.004535022657364607, -0.009706035256385803, 0.0009430805221199989, 0.006114226300269365, 0.019616737961769104, -0.007928800769150257, -0.006093698088079691, -0.0008764020167291164, -0.0007203243440017104, -0.012354194186627865, -0.006305190268903971, 0.001978836487978697, 0.02274858020246029, -0.021277762949466705, 0.045532938092947006, 0.013916299678385258, -0.014522142708301544, -0.004848946817219257, 0.008685818873345852, -0.02632303163409233, 0.010674982331693172, -0.01596755161881447, -0.00511926831677556, 0.0003356116358190775, -0.008355000987648964, 0.011158250272274017, 0.01246279664337635, -0.04877379909157753, 0.003972387406975031, 0.05970568582415581, 0.024673881009221077, 0.01410218421369791, -0.016128741204738617, -0.006866831332445145, -0.03216111660003662, -0.02597200870513916, -0.020400729030370712, 0.011261459439992905, -0.018408339470624924, 0.013928293250501156, -0.007329850923269987, 0.0011034252820536494, -0.014189381152391434, 0.00602920213714242, -0.01393035426735878, 0.010945611633360386, -0.009449802339076996, -0.025576535612344742, 0.01389610767364502, -0.01419486477971077, 0.01904253289103508, -0.026122944429516792, 0.005690614692866802, -0.02011829987168312, 0.05917388200759888, -0.009596859104931355, -0.019239021465182304, -0.01984224282205105, -0.026132645085453987, -0.0035313197877258062, -0.04872795194387436, 0.017057787626981735, 0.008425503969192505, 0.007923903875052929, -0.03921456262469292, 0.008044371381402016, -0.003833536058664322, 0.017193974927067757, 0.013000990264117718, -0.003597849979996681, -0.03581077232956886, -0.009015447460114956, 0.003488297341391444, 0.025153761729598045, -0.02006213366985321, 0.0009258314385078847, -0.024982085451483727, 0.035317789763212204, 0.00988171435892582, -0.01255481131374836, 0.02433236502110958, 0.013150135055184364, -0.007104505319148302, -0.002028718590736389, -0.015458228066563606, 0.018938524648547173, 0.001457903883419931, -0.03390295058488846, 0.012919657863676548, 0.011701122857630253, -0.006614969111979008, 0.0077001010067760944, 0.0035525583662092686, 0.0009641915094107389, 0.02402329444885254, 0.020752331241965294, 0.02702014520764351, -0.039226848632097244, 0.027937637642025948, -0.005152102094143629, 0.008586796931922436, -0.0032513889018446207, -0.009358098730444908, -0.001886721234768629, 0.03800184652209282, -0.01964738965034485, -0.011277725920081139, 0.002998529700562358, -0.004230480175465345, 0.0013867601519450545, -0.00479161785915494, 0.007321109529584646, 0.003731257515028119, -0.001086550299078226, 0.019536368548870087, -0.043584130704402924, -0.01282009482383728, -0.021723547950387, 0.012491071596741676, 0.018685903400182724, 0.02355785481631756, -0.011807960458099842, 0.0050752065144479275, -0.01767808571457863, -0.00041374436113983393, 0.002724234014749527, 0.004270641598850489, -0.01946922205388546, 0.0011809079442173243, 0.006362819112837315, -0.004364698193967342, -0.03320321813225746, -0.04647050052881241, -0.027584126219153404, 0.0003139219479635358, -0.012692797929048538, 0.04343739524483681, 2.976104588015005e-05, -0.020781371742486954, -0.016491195186972618, -0.005728599149733782, 0.0014096135273575783, 0.005672384053468704, -0.017700083553791046, -0.02008609101176262, -0.0017386502586305141, -0.0079606669023633, -0.03971327096223831, -0.04356054216623306, -0.007110267411917448, 0.007678365334868431, -0.008835704065859318, 0.019893277436494827, 0.0013545149704441428, -0.01373104378581047, 0.02572125755250454, -0.018528856337070465, -0.0003426643379498273, -0.018176252022385597, -0.0027032687794417143, -0.004147314466536045, -0.004384042229503393, -0.01042848452925682, -0.004536348395049572, -0.0587577261030674, -0.009146437980234623, 0.03461247682571411, 0.02369723841547966, 0.002016635611653328, 0.0135484728962183, 0.00922374241054058, -0.010114963166415691, -0.006613536737859249, -0.006791569758206606, -0.030637046322226524, 0.013923868536949158, -0.004589189775288105, -0.007555011194199324, 0.007769957650452852, -0.005451614502817392, -0.0003325599536765367, -0.01411769725382328, 0.024155864492058754, 0.014185523614287376, -0.006758952047675848, -0.0012016172986477613, -0.017330419272184372, -0.01579909399151802, 0.0051187556236982346, -0.0025322730652987957, -0.027936236932873726, -0.003676153253763914, -0.001264831400476396, 0.007177192252129316, -0.00936197116971016, 0.04181305691599846, -0.0285333264619112]}, 'query': {'bool': {'must': [{'match': {'content': {'query': '首创证券中财务报表和主要财务比率'}}}], 'filter': []}}, 'rank': {'rrf': {}}} Traceback (most recent call last): File "/root/AI/jiaxin.fan/test.py", line 272, in nodes = retriever_chunk.retrieve(query) File "/root/anaconda3/envs/LLM_310/lib/python3.10/site-packages/llama_index/core/instrumentation/dispatcher.py", line 198, in wrapper result = func(*args, kwargs) File "/root/anaconda3/envs/LLM_310/lib/python3.10/site-packages/llama_index/core/base/base_retriever.py", line 242, in retrieve nodes = self._retrieve(query_bundle) File "/root/anaconda3/envs/LLM_310/lib/python3.10/site-packages/llama_index/core/retrievers/recursive_retriever.py", line 206, in _retrieve retrievednodes, = self._retrieve_rec(query_bundle, query_id=None) File "/root/anaconda3/envs/LLM_310/lib/python3.10/site-packages/llama_index/core/retrievers/recursive_retriever.py", line 179, in _retrieve_rec nodes = obj.retrieve(query_bundle) File "/root/anaconda3/envs/LLM_310/lib/python3.10/site-packages/llama_index/core/instrumentation/dispatcher.py", line 198, in wrapper result = func(*args, *kwargs) File "/root/anaconda3/envs/LLM_310/lib/python3.10/site-packages/llama_index/core/base/base_retriever.py", line 242, in retrieve nodes = self._retrieve(query_bundle) File "/root/anaconda3/envs/LLM_310/lib/python3.10/site-packages/llama_index/core/instrumentation/dispatcher.py", line 198, in wrapper result = func(args, kwargs) File "/root/anaconda3/envs/LLM_310/lib/python3.10/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py", line 101, in _retrieve return self._get_nodes_with_embeddings(query_bundle) File "/root/anaconda3/envs/LLM_310/lib/python3.10/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py", line 177, in _get_nodes_with_embeddings query_result = self._vector_store.query(query, **self._kwargs) File "/root/anaconda3/envs/LLM_310/lib/python3.10/site-packages/llama_index/vector_stores/elasticsearch/base.py", line 413, in query return asyncio.get_event_loop().run_until_complete( File "/root/anaconda3/envs/LLM_310/lib/python3.10/site-packages/nest_asyncio.py", line 98, in run_until_complete return f.result() File "/root/anaconda3/envs/LLM_310/lib/python3.10/asyncio/futures.py", line 201, in result raise self._exception.with_traceback(self._exception_tb) File "/root/anaconda3/envs/LLM_310/lib/python3.10/asyncio/tasks.py", line 232, in step result = coro.send(None) File "/root/anaconda3/envs/LLM_310/lib/python3.10/site-packages/llama_index/vector_stores/elasticsearch/base.py", line 453, in aquery hits = await self._store.search( File "/root/anaconda3/envs/LLM_310/lib/python3.10/site-packages/elasticsearch/helpers/vectorstore/_async/vectorstore.py", line 277, in search response = await self.client.search( File "/root/anaconda3/envs/LLM_310/lib/python3.10/site-packages/elasticsearch/_async/client/init__.py", line 4114, in search return await self.perform_request( # type: ignore[return-value] File "/root/anaconda3/envs/LLM_310/lib/python3.10/site-packages/elasticsearch/_async/client/_base.py", line 271, in perform_request response = await self._perform_request( File "/root/anaconda3/envs/LLM_310/lib/python3.10/site-packages/elasticsearch/_async/client/_base.py", line 352, in _perform_request raise HTTP_EXCEPTIONS.get(meta.status, ApiError)( elasticsearch.BadRequestError: BadRequestError(400, 'parsing_exception', 'Unknown key for a START_OBJECT in [rank].')

dosubot[bot] commented 3 weeks ago

The error BadRequestError(400, 'parsing_exception', 'Unknown key for a START_OBJECT in [rank].') indicates that Elasticsearch does not recognize the rank field in your query. This typically happens when the query structure is not properly formatted for Elasticsearch.

To resolve this issue, ensure that your query structure adheres to Elasticsearch's expected format. Specifically, the rank field should be correctly defined or removed if not supported.

Here is a corrected version of your query without the rank field:


{
    "knn": {
        "filter": [],
        "field": "embedding",
        "query_vector": [0.020329274237155914, -0.016439935192465782, -0.01222333125770092, 0.020656481385231018, 0.015827272087335587, -0.00888893287628889, -0.01562308706343174, -0.03606059402227402, 0.04976935684680939, 0.029119601473212242, -0.002741447649896145, -0.016362575814127922, 0.0332820825278759, -0.019691595807671547, 0.012075891718268394, 0.0025564960669726133, -0.007536637596786022, 0.0033704356756061316, -0.02809642255306244, -0.02092575468122959, -0.005240238271653652, 0.025649499148130417, -0.004175655543804169, 0.025530824437737465, -0.0008253990672528744, -0.026714101433753967, 0.051027391105890274, 0.010184605605900288, 0.051661282777786255, -0.01330967340618372, -0.015519294887781143, 0.010468732565641403, -0.01525014080107212, 0.038076017051935196, 0.006049429532140493, 0.006912425626069307, -0.023785796016454697, 0.007381633389741182, 0.004440117161720991, -0.03070686198771, 0.019244011491537094, -0.003923557233065367, 0.02523256465792656, -0.06550795584917068, 0.001166821108199656, -0.017986014485359192, -0.017642419785261154, -0.027649110183119774, 0.007086060009896755, 0.0020284736528992653, 0.04732909053564072, -0.006779277231544256, -0.009489464573562145, 0.00970165804028511, -0.031571876257658005, 0.026365911588072777, 0.020602503791451454, 0.02348574995994568, -0.02765243500471115, -0.002478653797879815, -0.014957155101001263, 0.27513399720191956, 0.010376036167144775, 0.005817563738673925, -0.013377231545746326, 0.004174213390797377, 0.010696403682231903, 0.014416281133890152, -0.009168765507638454, -0.002566420705989003, 0.007733335718512535, -0.00025632293545641005, -0.003997491672635078, 0.024766208603978157, -0.00036237502354197204, 0.0059305704198777676, -0.00940575823187828, -0.014234567061066628, -0.009633033536374569, -0.013498012907803059, -0.011609544046223164, 0.007368254009634256, 0.030240189284086227, 0.003081308677792549, 0.017680330201983452, -0.016053877770900726, 0.03443997725844383, 0.6659529209136963, -0.0002952819922938943, 0.02241729013621807, 0.0077985720708966255, 0.018071888014674187, -0.023785114288330078, 0.0029143409337848425, -0.000205653443117626, -0.020456597208976746, 0.02079182118177414, -0.019969657063484192, -0.04976644366979599, -0.011992249637842178, 0.009986929595470428, 0.0076965647749602795, -0.03454209864139557, -0.017101813107728958, -0.021121185272932053, 0.014509577304124832, -0.021011877804994583, -0.0534089058637619, -0.009728622622787952, -0.030866747722029686, 0.028964322060346603, -0.01541442982852459, 0.0038019856438040733, -0.003983025439083576, -0.009112345054745674, 0.006359950173646212, 0.025645220652222633, 0.008345494978129864, 0.010245728306472301, 0.01649991050362587, 0.005208227783441544, 0.03587633743882179, -0.000737388210836798, -0.012415791861712933, 0.009661521762609482, 0.00028090932755731046, -0.005159290973097086, -0.008946229703724384, 0.011386929079890251, -0.013389317318797112, 0.017617151141166687, -0.014854146167635918, -0.001170898205600679, -0.005153430160135031, -0.009071567095816135, 0.02032872848212719, -0.01863989047706127, 0.008945468813180923, -0.0043152268044650555, -0.0005871430039405823, 0.03297213092446327, 0.001977963373064995, 0.0032101545948535204, -0.01854153722524643, 0.012299290858209133, -0.03360489010810852, -0.022069571539759636, 0.010739424265921116, 0.029817605391144753, -0.039313431829214096, 0.0015716489870101213, -0.02724459022283554, -0.023984072729945183, -0.040527909994125366, 0.0017336778109893203, -0.03894423693418503, 0.031406790018081665, 0.018498536199331284, 0.01690034009516239, -0.03053436428308487, 0.039694417268037796, 0.005342721473425627, 0.01161812525242567, 0.008850904181599617, -0.01020386628806591, 0.01215854100883007, 0.028949793428182602, -0.03002856858074665, 0.015785977244377136, 0.028102748095989227, -0.029611382633447647, 0.010397706180810928, 0.01067579910159111, 0.005819510202854872, 0.04110105335712433, -0.016545835882425308, 0.009348755702376366, 0.01860138773918152, 0.007365602068603039, 0.02483563870191574, 0.020235056057572365, 0.003951475024223328, 0.009940322488546371, -0.0042501045390963554, 0.0029419013299047947, 0.01893536187708378, 0.011640414595603943, -0.004167667590081692, -0.0018101197201758623, -0.03143971413373947, -0.017755940556526184, 0.021819330751895905, 0.029070472344756126, -0.04157961532473564, -0.015886230394244194, 0.013954048976302147, -0.0205618217587471, -0.01799621433019638, -0.006565671879798174, 0.000844244787003845, -0.02651955559849739, 0.016671115532517433, 0.003044463461264968, 0.02419034205377102, -0.007172714918851852, -0.02365092933177948, 0.013321282342076302, -0.00031893476261757314, 0.01822861097753048, 0.01686474122107029, -0.023543577641248703, -0.013733340427279472, 0.015345628373324871, 0.009825075976550579, -0.018069317564368248, -0.008895505219697952, -0.01804587058722973, -0.0041801417246460915, -0.01463606208562851, 0.01798340119421482, 0.0321781262755394, 0.009479745291173458, -0.011207050643861294, -0.018505094572901726, 0.019428031519055367, 0.004878494888544083, 0.0106356767937541, -0.02007715404033661, -0.02374391071498394, 0.008739382028579712, -0.024257132783532143, -0.012258431874215603, 0.023806722834706306, 0.0004211648483760655, -0.008512684144079685, -0.016982199624180794, 0.033339206129312515, -0.007792821153998375, -0.012508629821240902, 0.0011069371830672026, -0.017382115125656128, 0.008313643746078014, -0.004383585415780544, -0.03436248376965523, 0.0161832794547081, 0.004520326387137175, 0.014193883165717125, 0.02064836211502552, -0.014104579575359821, 0.005332938861101866, -0.0020291698165237904, -0.011023356579244137, 0.014824512414634228, -0.0521913506090641, 0.013545972295105457, -0.03431107848882675, -0.008948776870965958, 0.003895512316375971, 0.021302346140146255, 0.031358808279037476, 0.015384136699140072, 0.03233204782009125, -0.004017835948616266, -0.024872051551938057, -0.0056441486813127995, 0.008926626294851303, -0.0019570414442569017, 0.014668607152998447, -0.03666550666093826, 0.0015574299031868577, -0.011572553776204586, 0.027623092755675316, -0.022177448496222496, -0.03144596144556999, -0.020538663491606712, 0.004835388157516718, -0.0393996424973011, 0.012932831421494484, -0.010303341783583164, -0.009311350993812084, -0.021142536774277687, 0.008296611718833447, -0.029575901105999947, 0.0037163021042943, 0.012439648620784283, -0.0007158619118854403, -0.05201083794236183, -0.04657416045665741, 0.003529742592945695, -0.01051840279251337, -0.009037808515131474, 0.000571705459151417, 0.006366264540702105, -0.024444935843348503, -0.023829685524106026, 0.014127403497695923, 0.0015527429059147835, -0.018077656626701355, -0.039448488503694534, -0.018418220803141594, 0.04883118346333504, 0.005317091941833496, 0.004002789966762066, -0.015887761488556862, -0.002041307045146823, 0.054332684725522995, -0.0244329571723938, -0.030067533254623413, -0.006075720302760601, 0.0030039798002690077, -0.0017253872938454151, -0.026314137503504753, -0.00039545082836411893, -0.005224898923188448, 0.03044009394943714, -0.031966619193553925, 0.010867491364479065, -0.016902830451726913, -0.01546237152069807, 0.0362623892724514, 0.02198990434408188, 0.009067664854228497, -0.034472592175006866, -0.07338064163923264, 0.038962285965681076, 0.027712740004062653, 0.023937562480568886, 0.006155680865049362, 0.0005546078318729997, -0.04579202085733414, 0.015370846726000309, 0.022660881280899048, -0.042426448315382004, -0.019776029512286186, -0.00966611783951521, 0.02660316415131092, 0.04917048662900925, -0.032164834439754486, 0.009201363660395145, 0.0347210168838501, 0.010690328665077686, 0.012093733996152878, -0.05096052587032318, -0.035812363028526306, 0.022168433293700218, -0.030898461118340492, -0.0040168254636228085, 0.018580403178930283, -0.02248539961874485, -0.03651352971792221, 0.013269889168441296, 0.04591579735279083, 0.016993509605526924, 0.00690371124073863, 0.005806173197925091, -0.01064919400960207, -0.0038694667164236307, 0.03416285291314125, -0.008616657927632332, 0.022026756778359413, -0.006150258705019951, -0.0007132046739570796, 0.004886947106570005, 0.02638288587331772, -0.016298003494739532, -0.011570816859602928, -0.006847335025668144, 0.00901087187230587, -0.020307136699557304, -0.010206172242760658, 0.033569224178791046, 0.018402788788080215, -0.020970195531845093, -0.014239760115742683, 0.0175724308937788, -0.022900812327861786, -0.0089228805154562, -0.021260831505060196, 0.03815494850277901, -0.009230476804077625, 0.012139134109020233, -0.010677319020032883, -0.00732805859297514, 0.0350688211619854, 0.024879297241568565, 0.033575549721717834, 0.014400636777281761, 0.007072698790580034, 0.013797230087220669, 0.00478056725114584, -0.009797431528568268, -0.005149355623871088, -0.040338236

<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*