Use path_hierarchy tokenizer for attr paths (#584)

This commit is contained in:
Naïm Favier 2022-12-23 13:39:45 +01:00 committed by GitHub
parent 4bea45b150
commit d04f341a5d
Failed to generate hash of commit
4 changed files with 28 additions and 10 deletions

View file

@ -1 +1 @@
33
35

View file

@ -65,7 +65,11 @@ lazy_static! {
},
"package_attr_name": {
"type": "keyword",
"fields": {"edge": {"type": "text", "analyzer": "edge"}},
"fields": {
"edge": {"type": "text", "analyzer": "edge"},
"attr_path": {"type": "text", "analyzer": "attr_path"},
"attr_path_reverse": {"type": "text", "analyzer": "attr_path_reverse"}
},
},
"package_attr_set": {
"type": "keyword",
@ -125,11 +129,11 @@ lazy_static! {
// Options fields
"option_name": {
"type": "keyword",
"fields": {"edge": {"type": "text", "analyzer": "edge"}},
},
"option_name": {
"type": "keyword",
"fields": {"edge": {"type": "text", "analyzer": "edge"}},
"fields": {
"edge": {"type": "text", "analyzer": "edge"},
"attr_path": {"type": "text", "analyzer": "attr_path"},
"attr_path_reverse": {"type": "text", "analyzer": "attr_path_reverse"}
},
},
"option_description": {
"type": "text",
@ -155,14 +159,26 @@ lazy_static! {
"token_chars": [
"letter",
"digit",
// Either we use them or we would need to strip them before that.
"punctuation",
"symbol",
"custom",
],
// Exclude XML characters < and > from "symbol"
"custom_token_chars": "+=~",
},
"attr_path": {
"type": "path_hierarchy",
"delimiter": ".",
},
"attr_path_reverse": {
"type": "path_hierarchy",
"delimiter": ".",
"reverse": true,
},
},
"analyzer": {
"edge": {"tokenizer": "edge", "filter": ["lowercase"]},
"attr_path": {"tokenizer": "attr_path", "filter": ["lowercase"]},
"attr_path_reverse": {"tokenizer": "attr_path_reverse", "filter": ["lowercase"]},
"lowercase": {
"type": "custom",
"tokenizer": "keyword",

View file

@ -96,6 +96,7 @@
];
extraPackages = [
pkgs.rustfmt
pkgs.yarn
];
extraShellHook = ''
export RUST_SRC_PATH="${pkgs.rustPlatform.rustLibSrc}";
@ -115,6 +116,7 @@
devShells.frontend = mkDevShell {
inputsFrom = [packages.frontend] ;
extraPackages = [pkgs.rustfmt pkgs.yarn];
extraShellHook = ''
export PATH=$PWD/frontend/node_modules/.bin:$PATH
rm -rf frontend/node_modules

View file

@ -1232,7 +1232,7 @@ searchFields query mainField fields =
let
allFields =
fields
|> List.map (\( field, score ) -> [ field ++ "^" ++ String.fromFloat score, field ++ ".edge^" ++ String.fromFloat score ])
|> List.map (\( field, score ) -> [ field ++ "^" ++ String.fromFloat score, field ++ ".*^" ++ String.fromFloat score ])
|> List.concat
queryWords =