Imparare a classificarsi per Amazon OpenSearch Service - OpenSearch Servizio Amazon

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Imparare a classificarsi per Amazon OpenSearch Service

OpenSearch utilizza un framework di classificazione probabilistico chiamato BM-25 per calcolare i punteggi di pertinenza. Se una parola chiave distintiva appare più frequentemente in un documento, BM-25 assegna un punteggio di pertinenza più elevato a tale documento. Questo framework, tuttavia, non tiene conto del comportamento degli utenti come i dati click-through, che possono aumentare ulteriormente la rilevanza.

Learning to Rank è un plug-in OpenSearch open source che consente di utilizzare il machine learning e i dati comportamentali per ottimizzare la pertinenza dei documenti. Il plug-in utilizza modelli delle librerie XGBoost e Ranklib per assegnare un nuovo punteggio ai risultati della ricerca. Il plugin Elasticsearch LTR è stato inizialmente sviluppato da OpenSource Connections, con contributi significativi da Wikimedia Foundation, Snagajob Engineering, Bonsai e Yelp Engineering. La OpenSearch versione del plugin è derivata dal plugin Elasticsearch LTR.

Learning to Rank richiede Elasticsearch OpenSearch 7.7 o versione successiva. Per utilizzare il plug-in Learning to Rank, è necessario disporre delle autorizzazioni complete di amministratore. Per ulteriori informazioni, consultare Modifica dell'utente principale.

Nota

Questa documentazione fornisce una panoramica generale del plugin Learning to Rank e ti aiuta a iniziare a usarlo. La documentazione completa, comprese le descrizioni delle fasi e dell'API, è disponibile nella documentazione di Learning to Rank.

Nozioni di base su Learning to Rank

Devi fornire un elenco di giudizi, preparare un set di dati di addestramento e addestrare il modello al di fuori di Amazon OpenSearch Service. Le parti in blu si trovano al di fuori del OpenSearch servizio:

Esempio di processo del plug-in Learning to Rank.

Fase 1: Inizializzazione del plug-in

Per inizializzare il plugin Learning to Rank, invia la seguente richiesta al tuo dominio OpenSearch di servizio:

PUT _ltr
{ "acknowledged" : true, "shards_acknowledged" : true, "index" : ".ltrstore" }

Questo comando crea un indice .ltrstore nascosto che memorizza informazioni sui metadati, ad esempio set di funzioni e modelli.

Fase 2: Creazione di un elenco dei giudizi

Nota

È necessario eseguire questo passaggio al di fuori del OpenSearch Servizio.

Un elenco di giudizi è una raccolta di esempi da cui apprende un modello di machine learning. L'elenco dei giudizi deve includere parole chiave importanti e un insieme di documenti classificati per ogni parola chiave.

In questo esempio, abbiamo un elenco di giudizi per un set di dati di film. Un grado pari a 4 indica una corrispondenza perfetta. Un grado pari a 0 indica la corrispondenza peggiore.

Grado Parola chiave ID documento Nome del film
4 rambo 7555 Rambo
3 rambo 1370 Rambo III
3 rambo 1369 Rambo 2 - La vendetta
3 rambo 1368 La vendetta

Preparare l'elenco dei giudizi nel formato seguente:

4 qid:1 # 7555 Rambo 3 qid:1 # 1370 Rambo III 3 qid:1 # 1369 Rambo: First Blood Part II 3 qid:1 # 1368 First Blood where qid:1 represents "rambo"

Per un esempio più completo di un elenco dei giudizi, consultare Giudizi di film.

È possibile creare questo elenco di giudizi manualmente con l'aiuto di annotatori umani o dedurlo a livello di programmazione dai dati analitici.

Fase 3: Creazione di un set di funzionalità

Una funzionalità è un campo che corrisponde alla pertinenza di un documento, ad esempio title, overview, popularity score(numero di visualizzazioni) e così via.

Creare un set di funzionalità con un modello Mustache per ogni funzionalità. Per ulteriori informazioni sulle funzionalità, consultare Utilizzo delle funzionalità.

In questo esempio viene creato un set di funzionalità movie_features con i campi title e overview:

POST _ltr/_featureset/movie_features { "featureset" : { "name" : "movie_features", "features" : [ { "name" : "1", "params" : [ "keywords" ], "template_language" : "mustache", "template" : { "match" : { "title" : "{{keywords}}" } } }, { "name" : "2", "params" : [ "keywords" ], "template_language" : "mustache", "template" : { "match" : { "overview" : "{{keywords}}" } } } ] } }

Se si esegue una query sull'indice .ltrstore originale, viene recuperato il set di funzionalità:

GET _ltr/_featureset

Fase 4: Registrazione dei valori delle funzionalità

I valori delle funzionalità sono i punteggi di pertinenza calcolati da BM-25 per ogni funzionalità.

Combinare il set di funzionalità e l'elenco dei giudizi per registrare i valori delle funzionalità. Per ulteriori informazioni sulle funzionalità di registrazione, consultare Punteggi della funzionalità di registrazione.

In questo esempio, bool recupera i documenti classificati con il filtro e quindi seleziona il set di funzionalità con la query sltr. La query ltr_log combina i documenti e le funzionalità in modo da registrare i valori delle funzionalità corrispondenti:

POST tmdb/_search { "_source": { "includes": [ "title", "overview" ] }, "query": { "bool": { "filter": [ { "terms": { "_id": [ "7555", "1370", "1369", "1368" ] } }, { "sltr": { "_name": "logged_featureset", "featureset": "movie_features", "params": { "keywords": "rambo" } } } ] } }, "ext": { "ltr_log": { "log_specs": { "name": "log_entry1", "named_query": "logged_featureset" } } } }

L'aspetto di una risposta di esempio è simile al seguente:

{ "took" : 7, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 4, "relation" : "eq" }, "max_score" : 0.0, "hits" : [ { "_index" : "tmdb", "_type" : "movie", "_id" : "1368", "_score" : 0.0, "_source" : { "overview" : "When former Green Beret John Rambo is harassed by local law enforcement and arrested for vagrancy, the Vietnam vet snaps, runs for the hills and rat-a-tat-tats his way into the action-movie hall of fame. Hounded by a relentless sheriff, Rambo employs heavy-handed guerilla tactics to shake the cops off his tail.", "title" : "First Blood" }, "fields" : { "_ltrlog" : [ { "log_entry1" : [ { "name" : "1" }, { "name" : "2", "value" : 10.558305 } ] } ] }, "matched_queries" : [ "logged_featureset" ] }, { "_index" : "tmdb", "_type" : "movie", "_id" : "7555", "_score" : 0.0, "_source" : { "overview" : "When governments fail to act on behalf of captive missionaries, ex-Green Beret John James Rambo sets aside his peaceful existence along the Salween River in a war-torn region of Thailand to take action. Although he's still haunted by violent memories of his time as a U.S. soldier during the Vietnam War, Rambo can hardly turn his back on the aid workers who so desperately need his help.", "title" : "Rambo" }, "fields" : { "_ltrlog" : [ { "log_entry1" : [ { "name" : "1", "value" : 11.2569065 }, { "name" : "2", "value" : 9.936821 } ] } ] }, "matched_queries" : [ "logged_featureset" ] }, { "_index" : "tmdb", "_type" : "movie", "_id" : "1369", "_score" : 0.0, "_source" : { "overview" : "Col. Troutman recruits ex-Green Beret John Rambo for a highly secret and dangerous mission. Teamed with Co Bao, Rambo goes deep into Vietnam to rescue POWs. Deserted by his own team, he's left in a hostile jungle to fight for his life, avenge the death of a woman and bring corrupt officials to justice.", "title" : "Rambo: First Blood Part II" }, "fields" : { "_ltrlog" : [ { "log_entry1" : [ { "name" : "1", "value" : 6.334839 }, { "name" : "2", "value" : 10.558305 } ] } ] }, "matched_queries" : [ "logged_featureset" ] }, { "_index" : "tmdb", "_type" : "movie", "_id" : "1370", "_score" : 0.0, "_source" : { "overview" : "Combat has taken its toll on Rambo, but he's finally begun to find inner peace in a monastery. When Rambo's friend and mentor Col. Trautman asks for his help on a top secret mission to Afghanistan, Rambo declines but must reconsider when Trautman is captured.", "title" : "Rambo III" }, "fields" : { "_ltrlog" : [ { "log_entry1" : [ { "name" : "1", "value" : 9.425955 }, { "name" : "2", "value" : 11.262714 } ] } ] }, "matched_queries" : [ "logged_featureset" ] } ] } }

Nell'esempio precedente, la prima funzionalità non ha un valore di funzionalità perché la parola chiave "rambo" non viene visualizzata nel campo del titolo del documento con un ID uguale a 1368. Questo è un valore di funzionalità mancante nei dati di addestramento.

Fase 5: Creazione di un set di dati di addestramento

Nota

È necessario eseguire questa operazione al di fuori del OpenSearch Servizio.

Il passo successivo consiste nel combinare l'elenco dei giudizi e i valori delle funzionalità per creare un set di dati di addestramento. Se l'elenco dei giudizi originale ha la seguente struttura:

4 qid:1 # 7555 Rambo 3 qid:1 # 1370 Rambo III 3 qid:1 # 1369 Rambo: First Blood Part II 3 qid:1 # 1368 First Blood

Convertirlo nel set di dati di addestramento finale, che assomiglia a questo:

4 qid:1 1:12.318474 2:10.573917 # 7555 rambo 3 qid:1 1:10.357875 2:11.950391 # 1370 rambo 3 qid:1 1:7.010513 2:11.220095 # 1369 rambo 3 qid:1 1:0.0 2:11.220095 # 1368 rambo

È possibile eseguire questo passaggio manualmente o scrivere un programma per automatizzarlo.

Fase 6: Scelta di un algoritmo e costruzione del modello

Nota

È necessario eseguire questo passaggio al di fuori del OpenSearch Servizio.

Con il set di dati di addestramento in atto, il passo successivo è quello di utilizzare le librerie XGBoost o Ranklib per costruire un modello. Le librerie XGBoost e Ranklib consentono di costruire modelli popolari come LambdaMART, Random Forests e così via.

Per i passaggi per utilizzare XGBoost e Ranklib per creare il modello, consulta rispettivamente XGBoost e la documentazione. RankLib Per utilizzare Amazon per SageMaker creare il modello XGBoost, consulta XGBoost Algorithm.

Fase 7: Implementazione del modello

Dopo aver creato il modello, implementarlo nel plug-in Learning to Rank. Per ulteriori informazioni sull'implementazione di un modello, consultare Caricamento di un modello addestrato.

In questo esempio viene creato un modello my_ranklib_model utilizzando la libreria Ranklib:

POST _ltr/_featureset/movie_features/_createmodel?pretty { "model": { "name": "my_ranklib_model", "model": { "type": "model/ranklib", "definition": """## LambdaMART ## No. of trees = 10 ## No. of leaves = 10 ## No. of threshold candidates = 256 ## Learning rate = 0.1 ## Stop early = 100 <ensemble> <tree id="1" weight="0.1"> <split> <feature>1</feature> <threshold>10.357875</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-2.0</output> </split> <split pos="right"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <output>-2.0</output> </split> <split pos="right"> <output>-2.0</output> </split> </split> </split> <split pos="right"> <output>2.0</output> </split> </split> </tree> <tree id="2" weight="0.1"> <split> <feature>1</feature> <threshold>10.357875</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-1.67031991481781</output> </split> <split pos="right"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <output>-1.67031991481781</output> </split> <split pos="right"> <output>-1.6703200340270996</output> </split> </split> </split> <split pos="right"> <output>1.6703201532363892</output> </split> </split> </tree> <tree id="3" weight="0.1"> <split> <feature>2</feature> <threshold>10.573917</threshold> <split pos="left"> <output>1.479954481124878</output> </split> <split pos="right"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-1.4799546003341675</output> </split> <split pos="right"> <output>-1.479954481124878</output> </split> </split> <split pos="right"> <output>-1.479954481124878</output> </split> </split> </split> </tree> <tree id="4" weight="0.1"> <split> <feature>1</feature> <threshold>10.357875</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-1.3569872379302979</output> </split> <split pos="right"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <output>-1.3569872379302979</output> </split> <split pos="right"> <output>-1.3569872379302979</output> </split> </split> </split> <split pos="right"> <output>1.3569873571395874</output> </split> </split> </tree> <tree id="5" weight="0.1"> <split> <feature>1</feature> <threshold>10.357875</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-1.2721362113952637</output> </split> <split pos="right"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <output>-1.2721363306045532</output> </split> <split pos="right"> <output>-1.2721363306045532</output> </split> </split> </split> <split pos="right"> <output>1.2721362113952637</output> </split> </split> </tree> <tree id="6" weight="0.1"> <split> <feature>1</feature> <threshold>10.357875</threshold> <split pos="left"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-1.2110036611557007</output> </split> <split pos="right"> <output>-1.2110036611557007</output> </split> </split> <split pos="right"> <output>-1.2110037803649902</output> </split> </split> <split pos="right"> <output>1.2110037803649902</output> </split> </split> </tree> <tree id="7" weight="0.1"> <split> <feature>1</feature> <threshold>10.357875</threshold> <split pos="left"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-1.165616512298584</output> </split> <split pos="right"> <output>-1.165616512298584</output> </split> </split> <split pos="right"> <output>-1.165616512298584</output> </split> </split> <split pos="right"> <output>1.165616512298584</output> </split> </split> </tree> <tree id="8" weight="0.1"> <split> <feature>1</feature> <threshold>10.357875</threshold> <split pos="left"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-1.131177544593811</output> </split> <split pos="right"> <output>-1.131177544593811</output> </split> </split> <split pos="right"> <output>-1.131177544593811</output> </split> </split> <split pos="right"> <output>1.131177544593811</output> </split> </split> </tree> <tree id="9" weight="0.1"> <split> <feature>2</feature> <threshold>10.573917</threshold> <split pos="left"> <output>1.1046180725097656</output> </split> <split pos="right"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-1.1046180725097656</output> </split> <split pos="right"> <output>-1.1046180725097656</output> </split> </split> <split pos="right"> <output>-1.1046180725097656</output> </split> </split> </split> </tree> <tree id="10" weight="0.1"> <split> <feature>1</feature> <threshold>10.357875</threshold> <split pos="left"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-1.0838804244995117</output> </split> <split pos="right"> <output>-1.0838804244995117</output> </split> </split> <split pos="right"> <output>-1.0838804244995117</output> </split> </split> <split pos="right"> <output>1.0838804244995117</output> </split> </split> </tree> </ensemble> """ } } }

Per visualizzare il modello, inviare la seguente richiesta:

GET _ltr/_model/my_ranklib_model

Passaggio 8: Ricerca con Learning to Rank

Dopo aver implementato il modello, è possibile eseguire la ricerca.

Eseguire la query sltr con le funzionalità di cui si sta utilizzando e il nome del modello da eseguire:

POST tmdb/_search { "_source": { "includes": ["title", "overview"] }, "query": { "multi_match": { "query": "rambo", "fields": ["title", "overview"] } }, "rescore": { "query": { "rescore_query": { "sltr": { "params": { "keywords": "rambo" }, "model": "my_ranklib_model" } } } } }

Con Learning to Rank, "Rambo" viene visualizzato come primo risultato perché gli è stato assegnato il voto più alto nell'elenco dei giudizi:

{ "took" : 12, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 7, "relation" : "eq" }, "max_score" : 13.096414, "hits" : [ { "_index" : "tmdb", "_type" : "movie", "_id" : "7555", "_score" : 13.096414, "_source" : { "overview" : "When governments fail to act on behalf of captive missionaries, ex-Green Beret John James Rambo sets aside his peaceful existence along the Salween River in a war-torn region of Thailand to take action. Although he's still haunted by violent memories of his time as a U.S. soldier during the Vietnam War, Rambo can hardly turn his back on the aid workers who so desperately need his help.", "title" : "Rambo" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "1370", "_score" : 11.17245, "_source" : { "overview" : "Combat has taken its toll on Rambo, but he's finally begun to find inner peace in a monastery. When Rambo's friend and mentor Col. Trautman asks for his help on a top secret mission to Afghanistan, Rambo declines but must reconsider when Trautman is captured.", "title" : "Rambo III" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "1368", "_score" : 10.442155, "_source" : { "overview" : "When former Green Beret John Rambo is harassed by local law enforcement and arrested for vagrancy, the Vietnam vet snaps, runs for the hills and rat-a-tat-tats his way into the action-movie hall of fame. Hounded by a relentless sheriff, Rambo employs heavy-handed guerilla tactics to shake the cops off his tail.", "title" : "First Blood" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "1369", "_score" : 10.442155, "_source" : { "overview" : "Col. Troutman recruits ex-Green Beret John Rambo for a highly secret and dangerous mission. Teamed with Co Bao, Rambo goes deep into Vietnam to rescue POWs. Deserted by his own team, he's left in a hostile jungle to fight for his life, avenge the death of a woman and bring corrupt officials to justice.", "title" : "Rambo: First Blood Part II" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "31362", "_score" : 7.424202, "_source" : { "overview" : "It is 1985, and a small, tranquil Florida town is being rocked by a wave of vicious serial murders and bank robberies. Particularly sickening to the authorities is the gratuitous use of violence by two “Rambo” like killers who dress themselves in military garb. Based on actual events taken from FBI files, the movie depicts the Bureau’s efforts to track down these renegades.", "title" : "In the Line of Duty: The F.B.I. Murders" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "13258", "_score" : 6.43182, "_source" : { "overview" : """Will Proudfoot (Bill Milner) is looking for an escape from his family's stifling home life when he encounters Lee Carter (Will Poulter), the school bully. Armed with a video camera and a copy of "Rambo: First Blood", Lee plans to make cinematic history by filming his own action-packed video epic. Together, these two newfound friends-turned-budding-filmmakers quickly discover that their imaginative ― and sometimes mishap-filled ― cinematic adventure has begun to take on a life of its own!""", "title" : "Son of Rambow" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "61410", "_score" : 3.9719706, "_source" : { "overview" : "It's South Africa 1990. Two major events are about to happen: The release of Nelson Mandela and, more importantly, it's Spud Milton's first year at an elite boys only private boarding school. John Milton is a boy from an ordinary background who wins a scholarship to a private school in Kwazulu-Natal, South Africa. Surrounded by boys with nicknames like Gecko, Rambo, Rain Man and Mad Dog, Spud has his hands full trying to adapt to his new home. Along the way Spud takes his first tentative steps along the path to manhood. (The path it seems could be a rather long road). Spud is an only child. He is cursed with parents from well beyond the lunatic fringe and a senile granny. His dad is a fervent anti-communist who is paranoid that the family domestic worker is running a shebeen from her room at the back of the family home. His mom is a free spirit and a teenager's worst nightmare, whether it's shopping for Spud's underwear in the local supermarket", "title" : "Spud" } } ] } }

Se esegui una ricerca senza utilizzare il plug-in Learning to Rank, OpenSearch restituisce risultati diversi:

POST tmdb/_search { "_source": { "includes": ["title", "overview"] }, "query": { "multi_match": { "query": "Rambo", "fields": ["title", "overview"] } } }
{ "took" : 5, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 5, "relation" : "eq" }, "max_score" : 11.262714, "hits" : [ { "_index" : "tmdb", "_type" : "movie", "_id" : "1370", "_score" : 11.262714, "_source" : { "overview" : "Combat has taken its toll on Rambo, but he's finally begun to find inner peace in a monastery. When Rambo's friend and mentor Col. Trautman asks for his help on a top secret mission to Afghanistan, Rambo declines but must reconsider when Trautman is captured.", "title" : "Rambo III" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "7555", "_score" : 11.2569065, "_source" : { "overview" : "When governments fail to act on behalf of captive missionaries, ex-Green Beret John James Rambo sets aside his peaceful existence along the Salween River in a war-torn region of Thailand to take action. Although he's still haunted by violent memories of his time as a U.S. soldier during the Vietnam War, Rambo can hardly turn his back on the aid workers who so desperately need his help.", "title" : "Rambo" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "1368", "_score" : 10.558305, "_source" : { "overview" : "When former Green Beret John Rambo is harassed by local law enforcement and arrested for vagrancy, the Vietnam vet snaps, runs for the hills and rat-a-tat-tats his way into the action-movie hall of fame. Hounded by a relentless sheriff, Rambo employs heavy-handed guerilla tactics to shake the cops off his tail.", "title" : "First Blood" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "1369", "_score" : 10.558305, "_source" : { "overview" : "Col. Troutman recruits ex-Green Beret John Rambo for a highly secret and dangerous mission. Teamed with Co Bao, Rambo goes deep into Vietnam to rescue POWs. Deserted by his own team, he's left in a hostile jungle to fight for his life, avenge the death of a woman and bring corrupt officials to justice.", "title" : "Rambo: First Blood Part II" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "13258", "_score" : 6.4600153, "_source" : { "overview" : """Will Proudfoot (Bill Milner) is looking for an escape from his family's stifling home life when he encounters Lee Carter (Will Poulter), the school bully. Armed with a video camera and a copy of "Rambo: First Blood", Lee plans to make cinematic history by filming his own action-packed video epic. Together, these two newfound friends-turned-budding-filmmakers quickly discover that their imaginative ― and sometimes mishap-filled ― cinematic adventure has begun to take on a life of its own!""", "title" : "Son of Rambow" } } ] } }

In base a quanto si pensa che il modello stia funzionando, regolare l'elenco dei giudizi e le funzionalità. Ripetere quindi i passaggi da 2 a 8 per migliorare i risultati della classifica nel tempo.

API Learning to Rank

Utilizzare le operazioni di Learning to Rank per lavorare a livello di programmazione con set di funzionalità e modelli.

Creazione dell'archiviazione

Crea un indice .ltrstore nascosto che memorizza informazioni sui metadati, ad esempio set di funzionalità e modelli.

PUT _ltr

Eliminazione dell'archiviazione

Elimina l'indice .ltrstore nascosto e reimposta il plug-in.

DELETE _ltr

Creazione di un set di funzionalità

Crea un set di funzionalità.

POST _ltr/_featureset/<name_of_features>

Eliminazione di un set di funzionalità

Elimina un set di funzionalità.

DELETE _ltr/_featureset/<name_of_feature_set>

Ottenimento di un set di funzionalità

Recupera un set di funzionalità.

GET _ltr/_featureset/<name_of_feature_set>

Creazione del modello

Crea un modello.

POST _ltr/_featureset/<name_of_feature_set>/_createmodel

Eliminazione di un modello

Elimina un modello.

DELETE _ltr/_model/<name_of_model>

Ottenimento del modello

Recupera un modello.

GET _ltr/_model/<name_of_model>

Ottenimento delle statistiche

Fornisce informazioni sul comportamento del plug-in.

GET _ltr/_stats

Puoi anche utilizzare i filtri per recuperare una singola statistica:

GET _ltr/_stats/<stat>

Inoltre, puoi limitare le informazioni a un singolo nodo del cluster:

GET _ltr/_stats/<stat>/nodes/<nodeId> { "_nodes" : { "total" : 1, "successful" : 1, "failed" : 0 }, "cluster_name" : "873043598401:ltr-77", "stores" : { ".ltrstore" : { "model_count" : 1, "featureset_count" : 1, "feature_count" : 2, "status" : "green" } }, "status" : "green", "nodes" : { "DjelK-_ZSfyzstO5dhGGQA" : { "cache" : { "feature" : { "eviction_count" : 0, "miss_count" : 0, "entry_count" : 0, "memory_usage_in_bytes" : 0, "hit_count" : 0 }, "featureset" : { "eviction_count" : 2, "miss_count" : 2, "entry_count" : 0, "memory_usage_in_bytes" : 0, "hit_count" : 0 }, "model" : { "eviction_count" : 2, "miss_count" : 3, "entry_count" : 1, "memory_usage_in_bytes" : 3204, "hit_count" : 1 } }, "request_total_count" : 6, "request_error_count" : 0 } } }

Le statistiche sono fornite a due livelli, nodo e cluster, come specificato nelle tabelle seguenti:

Statistiche a livello di nodo
Nome campo Descrizione
request_total_count Conteggio totale delle richieste di classificazione.
request_error_count Conteggio totale delle richieste non riuscite.
cache Statistiche su tutte le cache (funzionalità, set di funzionalità, modelli). Una occorrenza della cache si verifica quando un utente esegue una query sul plug-in e il modello è già caricato in memoria.
cache.eviction_count Numero di rimozioni della cache.
cache.hit_count Numero di occorrenze della cache.
cache.miss_count Numero di mancati riscontri nella cache. Un mancato riscontro nella cache si verifica quando un utente esegue una query sul plug-in e il modello non è ancora caricato in memoria.
cache.entry_count Numero di voci nella cache.
cache.memory_usage_in_bytes Memoria totale utilizzata in byte.
cache.cache_capacity_reached Indica se viene raggiunto il limite della cache.
Statistiche a livello di cluster
Nome campo Descrizione
archiviazioni Indica dove vengono archiviati i set di funzionalità e i metadati del modello. (Il valore di default è “.ltrstore”. Altrimenti, viene aggiunto il prefisso “.ltrstore_” a un nome fornito dall'utente).
stores.status Stato dell'indice.
stores.feature_sets Numero di set di funzionalità.
stores.features_count Numero di funzionalità.
stores.model_count Numero di modelli.
status Lo stato del plug-in in base allo stato degli indici del feature store (rosso, giallo o verde) e allo stato dell'interruttore automatico (aperto o chiuso).
cache.cache_capacity_reached Indica se viene raggiunto il limite della cache.

Ottenimento delle statistiche della cache

Restituisce le statistiche sull'utilizzo della cache e della memoria.

GET _ltr/_cachestats { "_nodes": { "total": 2, "successful": 2, "failed": 0 }, "cluster_name": "opensearch-cluster", "all": { "total": { "ram": 612, "count": 1 }, "features": { "ram": 0, "count": 0 }, "featuresets": { "ram": 612, "count": 1 }, "models": { "ram": 0, "count": 0 } }, "stores": { ".ltrstore": { "total": { "ram": 612, "count": 1 }, "features": { "ram": 0, "count": 0 }, "featuresets": { "ram": 612, "count": 1 }, "models": { "ram": 0, "count": 0 } } }, "nodes": { "ejF6uutERF20wOFNOXB61A": { "name": "opensearch1", "hostname": "172.18.0.4", "stats": { "total": { "ram": 612, "count": 1 }, "features": { "ram": 0, "count": 0 }, "featuresets": { "ram": 612, "count": 1 }, "models": { "ram": 0, "count": 0 } } }, "Z2RZNWRLSveVcz2c6lHf5A": { "name": "opensearch2", "hostname": "172.18.0.2", "stats": { ... } } } }

Cancellazione della cache

Cancella la cache del plug-in. Utilizzare questa opzione per aggiornare il modello.

POST _ltr/_clearcache