Mutation of returned _source data in results by highlightResults function
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- elasticsearch, javascript
- Ambito
- databases
Direzione di ricerca
Inizia in src/utils/helper.js leggendo highlightResults e parseHits, poi analizza come i risultati evidenziati vengono restituiti ai chiamanti. Il lavoro è completato quando il risultato evidenziato continua a esporre tutti i dati completi di _source invece di sostituire i campi con valori evidenziati troncati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
When a user specifies they want their data to be highlighted the highlighted data returns a truncated portion in the _source.
Please see my comments below. I didn't think a pull request was appropriate as all I would be doing is deleting a function.
Is there a reason for mutating the source of the highlighted data?
Best,
Ryan
// src/utils/helper.js
// Why are we mutating the original _source object here?
// This takes away information for the end-user given by elasticsearch
// My use case of ElasticSearch is to store parsed pdfs as strings
// These contain 1000+ chars each
// The highlighted information given by elasticsearch have many fewer characters than this.
// Around 100 chars
// I want to be able to send the whole of the information to the end-user in the results
// If you remove this function (highlightResults)
// the user still retains the highlighted information in the main result object
// and the original _source information
const highlightResults = (result) => {
const data = { ...result };
if (data.highlight) {
Object.keys(data.highlight).forEach((highlightItem) => {
const highlightValue = data.highlight[highlightItem][0];
data._source = Object.assign({}, data._source, { [highlightItem]: highlightValue });
});
}
return data;
};
export const parseHits = (hits) => {
let results = null;
if (hits) {
results = [...hits].map((item) => {
const streamProps = {};
if (item._updated) {
streamProps._updated = item._updated;
} else if (item._deleted) {
streamProps._deleted = item._deleted;
}
// no need to mutate the data! below
const data = highlightResults(item);
return {
_id: data._id,
_index: data._index,
...data._source,
...streamProps,
};
});
}
return results;
};
- Lingua principale
- JavaScript
- Stelle
- 33
- Fork
- 27
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di appbaseio/reactivecore
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 42/100
appbaseio/reactivecore#69 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
appbaseio/reactivecore#52 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
appbaseio/reactivecore#47 · 2 reazioni ·
-
Allow customization of GraphQL fetchForse di nuovo libera @lakhansamani l’ha presa 2197 giorni fa e non c’è nessuna pull request aperta. Aperta
appbaseio/reactivecore#42 · 2 commenti · 1 reazione · 1 assegnatario ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
appbaseio/reactivecore#29 · 4 commenti ·
Tutte le issue di appbaseio/reactivecore
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Query Log shows "Upstream" for CNAME cloaking, schedule, NXDOMAIN hijack and response IP blocksApertabug good first issue query-log web
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
ferrous-networking/ferrous-dns#326 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
Ylianst/MeshCentral#8294 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
yunaremaia/jsonl-cli#1 · 1 commento ·