From 3812a0650ed97e7702fe7d52a6d9799f6778af83 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Fri, 9 Jun 2023 15:11:14 -0700 Subject: [PATCH] Global search improvements. --- server/opensearch/os-handler.js | 56 +++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/server/opensearch/os-handler.js b/server/opensearch/os-handler.js index 1266e6a6c..0bc72170c 100644 --- a/server/opensearch/os-handler.js +++ b/server/opensearch/os-handler.js @@ -86,6 +86,7 @@ async function OpenSearchUpdateHandler(req, res) { "v_model_yr", "v_make_desc", "v_model_desc", + "v_vin", ]); document.bodyshopid = req.body.event.data.new.shopid; break; @@ -139,7 +140,7 @@ async function OpenSearchUpdateHandler(req, res) { "exported_at", "invoice_number", "is_credit_memo", - "total" + "total", ]), ...bill.bills_by_pk, bodyshopid: bill.bills_by_pk.job.shopid, @@ -244,17 +245,54 @@ async function OpensearchSearchHandler(req, res) { bool: { must: [ { - multi_match: { - query: search, - type: "phrase_prefix", - //fields: ["*"], - // fuzziness: "5", - //prefix_length: 2, + match: { + bodyshopid: assocs.associations[0].shopid, }, }, { - match: { - bodyshopid: assocs.associations[0].shopid, + bool: { + should: [ + { + multi_match: { + query: search, + type: "cross_fields", + fields: ["*ownr_fn", "*ownr_ln"], + }, + }, + { + multi_match: { + query: search, + type: "most_fields", + fields: [ + "*v_model_yr", + "*v_make_desc^2", + "*v_model_desc^3", + ], + }, + }, + { + query_string: { + query: `*${search}*`, + + fields: [ + "*ro_number^20", + "*clm_no^14", + "*v_vin^12", + "*plate_no^12", + "*ownr_ln^10", + "transactionid^10", + "paymentnum^10", + "invoice_number^10", + "*ownr_fn^8", + "*ownr_co_nm^8", + "*ownr_ph1^8", + "*ownr_ph2^8", + "*", + ], + }, + }, + ], + minimum_should_match: 1, }, }, ],