Commit 6b3c8e88 authored by Remi Mélisson's avatar Remi Mélisson
Browse files

feat: ignore diatrics #36

parent 645f122e
......@@ -2,6 +2,7 @@
exports[`Test entreprise search correct siren 1`] = `
Object {
"activitePrincipale": "Fabrication et rechapage de pneumatiques",
"conventions": Array [
Object {
"etat": "VIGUEUR_ETEN",
......@@ -29,8 +30,8 @@ Object {
"label": "MANUF FRANC PNEUMATIQ MICHELIN",
"matching": 26,
"matchingEtablissement": Object {
"address": "Route d'Arles 13300 Salon-de-Provence",
"siret": "85520050703094",
"address": "16 Rue de Toutlemonde 49300 Cholet",
"siret": "85520050700710",
},
"simpleLabel": "MANUF FRANC PNEUMATIQ MICHELIN",
"siren": "855200507",
......@@ -39,7 +40,8 @@ Object {
exports[`Test etablissement search correct siret 1`] = `
Object {
"address": "Route d'Arles 13300 Salon-de-Provence",
"activitePrincipale": "Fabrication et rechapage de pneumatiques",
"address": "16 Rue de Toutlemonde 49300 Cholet",
"convention": Object {
"etat": "VIGUEUR_ETEN",
"id": "KALICONT000005635597",
......@@ -56,12 +58,13 @@ Object {
"matching": 1,
"simpleLabel": "MANUF FRANC PNEUMATIQ MICHELIN",
"siren": "855200507",
"siret": "85520050703094",
"siret": "85520050700710",
}
`;
exports[`Test search generic search 1`] = `
Object {
"activitePrincipale": "Fabrication et rechapage de pneumatiques",
"conventions": Array [
Object {
"etat": "VIGUEUR_ETEN",
......@@ -89,8 +92,8 @@ Object {
"label": "MANUF FRANC PNEUMATIQ MICHELIN",
"matching": 18,
"matchingEtablissement": Object {
"address": "Route d'Arles 13300 Salon-de-Provence",
"siret": "85520050703094",
"address": "16 Rue de Toutlemonde 49300 Cholet",
"siret": "85520050700710",
},
"simpleLabel": "MANUF FRANC PNEUMATIQ MICHELIN",
"siren": "855200507",
......
......@@ -23,7 +23,7 @@ const searchCall = (
};
const michelinSiren = "855200507";
const michelinSiret = `${michelinSiren}03094`;
const michelinSiret = `${michelinSiren}00710`;
describe("Test search", () => {
test("generic search", async () => {
......@@ -47,7 +47,7 @@ describe("Test search", () => {
const { body: b1 } = await searchCall("michelin", undefined, undefined);
expect(
b1.entreprises[0].matchingEtablissement.address
).toMatchInlineSnapshot(`"Route d'Arles 13300 Salon-de-Provence"`);
).toMatchInlineSnapshot(`"16 Rue de Toutlemonde 49300 Cholet"`);
const { body: b2 } = await searchCall("michelin", "63 000", undefined);
expect(
......@@ -62,6 +62,22 @@ describe("Test search", () => {
).toMatchInlineSnapshot(
`"23 Place des Carmes Dechaux 63000 Clermont-Ferrand"`
);
const { body: b4 } = await searchCall("michelin", "63", undefined);
expect(
b4.entreprises[0].matchingEtablissement.address
).toMatchInlineSnapshot(
`"23 Place des Carmes Dechaux 63000 Clermont-Ferrand"`
);
});
test("search with daitrics", async () => {
const { body: b1 } = await searchCall("michelin", undefined, undefined);
const { body: b2 } = await searchCall("michélin", undefined, undefined);
const { body: b3 } = await searchCall("Mîchèlin", undefined, undefined);
expect(b1).toStrictEqual(b2);
expect(b1).toStrictEqual(b3);
});
test("search with siret", async () => {
......
......@@ -178,7 +178,12 @@ export const entrepriseSearchBody = (
},
},
],
should: [{ rank_feature }],
should: [
{ rank_feature },
// rank by siret with minimum boosting in order to ensure results appear in the same order
// useful to always have the same first etablissement when no address passed
{ rank_feature: { field: "siretRank", boost: 0.1 } },
],
},
},
size: size ? size : defaultLimit,
......
......@@ -55,6 +55,8 @@ const analysis = {
filter: [
"french_elision",
"lowercase",
// company labels do not include diatrics
"asciifolding",
"french_stop",
"french_stemmer",
// very important filter in order to remove duplication between
......
......@@ -48,7 +48,7 @@ export type Enterprise = {
export const mappings = {
properties: {
trancheEffectifsUniteLegale: { type: "rank_feature" },
siretRank: { type: "rank_feature" },
etablissements: { type: "rank_feature" },
siret: { type: "keyword" },
......@@ -105,8 +105,11 @@ export const mapEnterprise = (enterprise: Enterprise) => {
!Number.parseFloat(
(enterprise.trancheEffectifsUniteLegale as unknown) as string
)
)
) {
enterprise.trancheEffectifsUniteLegale = 0.1;
}
const siretRank = enterprise.siret;
const naming = Array.from(
new Set([
......@@ -160,6 +163,7 @@ export const mapEnterprise = (enterprise: Enterprise) => {
activitePrincipale,
convention,
withIdcc,
siretRank,
...Object.fromEntries(
Object.entries(enterprise).filter(([k, v]) => k && v)
),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment