Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

190
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda