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

161
Vistas
how to fetch data from elastic search in node js?

I am using NODE JS with elastic search DB . I am using this package https://www.npmjs.com/package/@elastic/elasticsearch I have this collection in my elastic search DB

[
  {
    "_index": "products",
    "_id": "wZRh3n8Bs9qQzO6fvTTS",
    "_score": 1.0,
    "_source": {
      "title": "laptop issues",
      "description": "laptop have issue present in according"
    }
  },
  {
    "_index": "products",
    "_id": "wpRh3n8Bs9qQzO6fvzQM",
    "_score": 1.0,
    "_source": {
      "title": "buy mobile",
      "description": "mobile is in Rs 250"
    }
  },
  {
    "_index": "products",
    "_id": "w5Rh3n8Bs9qQzO6fvzTz",
    "_score": 1.0,
    "_source": {
      "title": "laptop payment",
      "description": "laptop payment is given in any way"
    }
  }
]

now I am planning to fetch data from elastic DB . when I am passing "LAP" or "lap" . it is giving me blank array or [] array why ? "lap" is present in all object

I am doing like that

 const result= await client.search({
      index: 'products',
      query: {
        match_phrase: {
            description: "lap"
        }
      }  

where I am doing wrong . I need all result where lap keywords is present

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Match query is not working because you are trying to search partial character of laptop term.

You can use Prefix Query for single term like below:

{
  "query": {
    "prefix": {
      "title": {
        "value": "lap"
      }
    }
  }
}

If you want to search for phrase then you can use Phrase Prefix Query:

{
  "query": {
    "match_phrase_prefix": {
      "title": "lap"
    }
  }
}

If you want to match only some of the word from query then you can use match query with operator set to or.

POST querycheck/_search
{
  "query": {
    "match": {
      "title": {
        "query": "i have issues",
        "operator": "or"
      }
    }
  }
}
about 4 years ago · Juan Pablo Isaza 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