Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Validating the number of clauses in DataSearch component

Abierto
#1,519 5 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@bietkul ya está trabajando en esto.

Desde el 31/7/2020.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

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;
}
Lenguaje dominante
JavaScript
Estrellas
4.9k
Forks
479
Merge medio
4 d 10 h
PR fusionados (30 d)
4

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de appbaseio/reactivesearch

Todos los issues de appbaseio/reactivesearch

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.