Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Validating the number of clauses in DataSearch component

Aperta
#1,519 5 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@bietkul ci sta già lavorando.

Dal 31/7/2020.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug

React

There's a default ElasticSearch limit of 1024 clauses within a query. Users may reach this limit when pasting a long list of values to search against within the DataSearch component. In my case it crashes ElasticSearch and returns the error "caused_by":{"type":"too_many_clauses","reason":"maxClauseCount is set to 1024"}.

It would be great if there was a way of setting a limit/validating entries once this limit is reached to prevent ElasticSearch from crashing. I'm trying to solve this by using beforeValueChange to reject the entry if it's greater than 1024. But I need to be able to reset the promise and the value the user has entered so they can start again. With the code below, the promise is rejected and the user can no longer edit the input. Any suggestions? Thanks

beforeValueChange={
       (value) => {
           return new Promise((resolve, reject) => {
                   if (withinElasticSearchMaxClauseLimit(value)) {
                          resolve();
                   } else {
                          // how do I clear the user entered value and reset the promise here?
                          reject();
                  }

           })
      }
}

function withinElasticSearchMaxClauseLimit(str) {
    str = str.replace(/(^\s*)|(\s*$)/gi, "");
    str = str.replace(/[ ]{2,}/gi, " ");
    str = str.replace(/\n /, "\n");
    return str.split(' ').length <= 1024;
}
Lingua principale
JavaScript
Stelle
4.9k
Fork
479
Merge medio
4g 10h
PR unite (30g)
4

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di appbaseio/reactivesearch

Tutte le issue di appbaseio/reactivesearch

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.