|
@@ -112,8 +112,8 @@ async function buscarAtendimentosPorTexto({ termos, setor, status, limit = BUSCA
|
|
|
|
|
|
|
|
let ranqueados = await AtendimentoMensagem.query()
|
|
let ranqueados = await AtendimentoMensagem.query()
|
|
|
.select("AtendimentoId")
|
|
.select("AtendimentoId")
|
|
|
- .select(AtendimentoMensagem.knex().raw("MAX(MATCH(Body) AGAINST(? IN NATURAL LANGUAGE MODE)) as relevancia", [termo]))
|
|
|
|
|
- .whereRaw("MATCH(Body) AGAINST(? IN NATURAL LANGUAGE MODE)", [termo])
|
|
|
|
|
|
|
+ .select(AtendimentoMensagem.knex().raw("MAX(MATCH(Body, Transcricao) AGAINST(? IN NATURAL LANGUAGE MODE)) as relevancia", [termo]))
|
|
|
|
|
+ .whereRaw("MATCH(Body, Transcricao) AGAINST(? IN NATURAL LANGUAGE MODE)", [termo])
|
|
|
.groupBy("AtendimentoId")
|
|
.groupBy("AtendimentoId")
|
|
|
.orderBy("relevancia", "desc")
|
|
.orderBy("relevancia", "desc")
|
|
|
.limit(limit);
|
|
.limit(limit);
|
|
@@ -126,7 +126,7 @@ async function buscarAtendimentosPorTexto({ termos, setor, status, limit = BUSCA
|
|
|
ranqueados = (
|
|
ranqueados = (
|
|
|
await AtendimentoMensagem.query()
|
|
await AtendimentoMensagem.query()
|
|
|
.select("AtendimentoId")
|
|
.select("AtendimentoId")
|
|
|
- .whereRaw("Body LIKE ?", [`%${termo}%`])
|
|
|
|
|
|
|
+ .whereRaw("(Body LIKE ? OR Transcricao LIKE ?)", [`%${termo}%`, `%${termo}%`])
|
|
|
.groupBy("AtendimentoId")
|
|
.groupBy("AtendimentoId")
|
|
|
.limit(limit)
|
|
.limit(limit)
|
|
|
).map((r) => ({ AtendimentoId: r.AtendimentoId }));
|
|
).map((r) => ({ AtendimentoId: r.AtendimentoId }));
|