Skip to content

Commit

Permalink
fix(es): re-make slug a keyword (#1969)
Browse files Browse the repository at this point in the history
* fix(es): re-make slug a keyword

* fix: s/match/term

* fix(api): replace must with a filter query
  • Loading branch information
Julien Bouquillon authored Dec 17, 2019
1 parent 13a5136 commit 447ebfc
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ exports[`return item from source and slug 1`] = `
Object {
"_id": "2",
"_index": "cdtn_document_test",
"_score": 7.277507,
"_score": 0,
"_source": Object {
"breadcrumbs": Array [
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Object {
],
"documents": Array [
Object {
"_score": 7.277507,
"_score": 0,
"algo": "pre-qualified",
"breadcrumbs": Array [
Object {
Expand All @@ -152,15 +152,15 @@ Object {
"url": "https://www.service-public.fr/particuliers/vosdroits/F2883",
},
Object {
"_score": 11.7543745,
"_score": 0,
"algo": "pre-qualified",
"description": "Le Code du travail ne prévoit aucune forme particulière pour présenter sa démission : elle peut être verbale, écrite ou résulter d’un comportement sans ambiguïté du salarié (ce qui n’est pas le cas, par exemple, de la seule absence du salarié à son poste de travail ou de l’absence de reprise du travail à l’issue des congés payés).",
"slug": "la-demission#Comment-presenter-une-demission",
"source": "fiches_ministere_travail",
"title": "La démission : comment présenter une démission ?",
},
Object {
"_score": 10.619121,
"_score": 0,
"algo": "pre-qualified",
"breadcrumbs": Array [
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ function getSearchBody({ source, slug }) {
size: 1,
query: {
bool: {
must: [
filter: [
{
match: { source }
term: { source }
},
{
match: { slug }
term: { slug }
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,9 @@ const getDocumentByUrlQuery = (
size: 1,
query: {
bool: {
must: [
{
match: {
slug: {
query: slug,
minimum_should_match: "70%"
}
}
},
{
term: {
source: getSourceByRoute(source)
}
}
filter: [
{ term: { slug } },
{ term: { source: getSourceByRoute(source) } }
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function getSheetMTQuery({ slug }) {
bool: {
filter: {
term: {
"slug.asKeyword": slug
slug
}
}
}
Expand Down
7 changes: 1 addition & 6 deletions packages/code-du-travail-data/indexing/document.mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ export const documentMapping = {
},
// The local document slug
slug: {
type: "text",
fields: {
asKeyword: {
type: "keyword"
}
}
type: "keyword"
},
// The source URL
url: {
Expand Down

0 comments on commit 447ebfc

Please sign in to comment.