Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seems * can not be used in FTS ? #257

Open
oddpxl opened this issue Mar 31, 2024 · 1 comment
Open

Seems * can not be used in FTS ? #257

oddpxl opened this issue Mar 31, 2024 · 1 comment

Comments

@oddpxl
Copy link

oddpxl commented Mar 31, 2024

..or am I doing something wrong ?

Search result: Err( × --> 1:1
│ |
│ 1 | *arlie
│ | ^---
│ |
│ = expected fts_expr

`

let result = db.run_script(
    "::fts create people:index_name {
        extractor: name,
        extract_filter: !is_null(name),
        tokenizer: Simple,
        filters:[Lowercase, Stemmer('english'), Stopwords('en')]
    }", 
    BTreeMap::new(),
    ScriptMutability::Mutable
);

println!("Index result: {:?}", result);

let mut parameters = BTreeMap::new();
parameters.insert("q".to_string().into(), DataValue::Str("*arlie".to_string().into()));
let result = db.run_script(
    "?[score, name, age] := ~people:index_name {name, age | query: $q, k: 10, filter: 1 + 1 == 2, score_kind: 'tf', bind_score: score }
    :order -score
    ", 
    parameters,
    ScriptMutability::Immutable
);

println!("Search result: {:?}", result);`
@creatorrr
Copy link
Contributor

Yeah I can confirm that fts query with a prefixed star doesn't work.

REPL example:

=> :create people { name: String }
 status
--------
 "OK"

=> ::fts create people:index_name {
        extractor: name,
        extract_filter: !is_null(name),
        tokenizer: Simple,
        filters:[Lowercase, Stemmer('english'), Stopwords('en')]
    }
 status
--------
 "OK"

=> ?[name] <- [['Diwank']] :insert people {name}
 status
--------
 "OK"

=> ?[name] := ~people:index_name {name | query: 'wank', k: 10}
 name
------

=> ?[name] := ~people:index_name {name | query: 'Diwank', k: 10}
 name
----------
 "Diwank"

=> ?[name] := ~people:index_name {name | query: '*wank', k: 10}
  ×  --> 1:1
  │   |
  │ 1 | *wank
  │   | ^---
  │   |
  │   = expected fts_expr

=> ?[name] := ~people:index_name {name | query: 'Di*', k: 10}
 name
------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants