Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

195
Vistas
How to use a "where not" clause with searchkick

I am using Searchkick with Elasticsearch to get products with a search term.

I am trying to add a WHERE NOT clause to it so it won't return any products with a regular_price that is null.

@products = Product.search(
        search,
        where: {
          regular_price: {
            not: "null" # I have also tried nil, both won't work
          }
        },
        page: params[:page],
        per_page: per_page,
      )

The search ignores my WHERE NOT clause.

I would also be grateful for some debugging tips for this.

Edit:

So I have tried to use the following but now it just returns every product that fits the search. Ignoring the WHERE NOT part of the search.

@products = Product.search(
        search,
        where: {
          regular_price: {
            _not: "null" 
          }
        },
        page: params[:page],
        per_page: per_page,
      )

UPDATE:

I have not found a solution to this issue and I moved on with a diffrent approach. By filtering out the products with a regular_price of 0.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

@products = Product.search(
    search,
    where: {
      regular_price: {
        _not: nil 
      }
    },
    page: params[:page],
    per_page: per_page,
  )

Just replace "null" with nil and it would filter out the products that don't have regular_price.

over 4 years ago · Santiago Trujillo Denunciar

0

Haven't found an answer yet. Because there aren't many products that I want to filter out with this query, I just filter them out while rendering.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda