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

95
Vistas
How to use select on azure search suggesters

I'm using Azure search on my project, and I want to do an autocomplete text field, it works as expected. here's the code :

const suggestItems = async (req, res) => {

try {

    // Reading inputs from HTTP Request

    const q = (req.query.q || (req.body && req.body.q));

    const top = (req.query.top || (req.body && req.body.top));

    const suggester = (req.query.suggester || (req.body && req.body.suggester));

    // Let's get the top 5 suggestions for that search term

    const suggestions = await client.suggest(q, suggester, {  top: parseInt(top) });

    //const suggestions = await client.autocomplete(q, suggester, {top: parseInt(top)});

    console.log(suggestions.results)

    return res.status(status.OK)

    .json({ suggestions: suggestions.results})

   

} catch (error) {

    handleError(res, error)

}

 }

her's the result :

[

{ text: 'Alpha Aromatics (MA)', document: { id: '4' } },

{ text: 'Alpha Aromatics (USA)', document: { id: '5' } },

{ text: 'Art Land - Winter Palace', document: { id: '6' } },

 { text: 'Alpha Aromatics (USA)', document: { id: '3' } }

]

here's the quesry passed by postman :

{

"q":"ar","top":5,"suggester":"sg"

 }

but the problem is , on the result I have just the text and the id of the document , I'm looking for other fields like status for example, how can get that please ?

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

0

I am guessing "Status" is one of your index fields, from the question. You need to make sure you mark the fields you need to be returned in the results as retrievable in your index definition. It looks you only have text and id fields as retrievable. For more information: https://docs.microsoft.com/en-us/azure/search/search-what-is-an-index.

Example:

enter image description here

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