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": { "package_attr_name": {
"type": "keyword", "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": { "package_attr_set": {
"type": "keyword", "type": "keyword",
@ -125,11 +129,11 @@ lazy_static! {
// Options fields // Options fields
"option_name": { "option_name": {
"type": "keyword", "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_name": {
"type": "keyword",
"fields": {"edge": {"type": "text", "analyzer": "edge"}},
}, },
"option_description": { "option_description": {
"type": "text", "type": "text",
@ -155,14 +159,26 @@ lazy_static! {
"token_chars": [ "token_chars": [
"letter", "letter",
"digit", "digit",
// Either we use them or we would need to strip them before that.
"punctuation", "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": { "analyzer": {
"edge": {"tokenizer": "edge", "filter": ["lowercase"]}, "edge": {"tokenizer": "edge", "filter": ["lowercase"]},
"attr_path": {"tokenizer": "attr_path", "filter": ["lowercase"]},
"attr_path_reverse": {"tokenizer": "attr_path_reverse", "filter": ["lowercase"]},
"lowercase": { "lowercase": {
"type": "custom", "type": "custom",
"tokenizer": "keyword", "tokenizer": "keyword",

View file

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

View file

@ -1232,7 +1232,7 @@ searchFields query mainField fields =
let let
allFields = allFields =
fields 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 |> List.concat
queryWords = queryWords =