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

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

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 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