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

Bug: When using Mem locally, search::highlight('<b>', '</b>', 1, true) does not support the fourth parameter #3922

Open
2 tasks done
maoly1012 opened this issue Apr 22, 2024 · 0 comments
Assignees
Labels
bug Something isn't working topic:indexing This is related to indexing and full-text search

Comments

@maoly1012
Copy link

Describe the bug

When using Mem locally, search::highlight('', '', 1, true) does not support the fourth parameter, and the error is "Incorrect arguments for function search::highlight ()." Expected 3 arguments ".

Steps to reproduce

`use serde::{Deserialize, Serialize};
use surrealdb::engine::local::Mem;
use surrealdb::sql::Thing;
use surrealdb::Surreal;
#[derive(Debug, Serialize)]
struct Person<'a> {
title: &'a str,
name: &'a str,
marketing: bool,
}

#[derive(Debug, Deserialize)]
struct Record {
#[allow(dead_code)]
id: Thing,
}

#[tokio::main]
async fn main() -> surrealdb::Result<()> {
// Connect to the server
let db = Surreal::new::(()).await?;
// Select a specific namespace / database
db.use_ns("test").use_db("test").await?;
db.query("DEFINE ANALYZER ngram_search TOKENIZERS blank, class, punct FILTERS lowercase, ngram(1,10)")
.query("DEFINE INDEX ngram_search_index ON person COLUMNS title SEARCH ANALYZER ngram_search BM25 HIGHLIGHTS").await?;
// Create a new person with a random id
let created: Vec = db
.create("person")
.content(Person {
title: "Founder & CEO",
name: "Morgan Hitchcock",
marketing: true,
})
.await?;
dbg!(created);
// Perform a custom advanced query
let groups = db
.query("SELECT title, search::highlight('', '', 1, true) as high FROM person where title @1@ 'Founder'")
.await?;
dbg!(groups);
Ok(())
}`

Expected behaviour

response title "Founder & CEO" and the highlight title

SurrealDB version

surreal 1.4.2 on windows 11

Contact Details

No response

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@maoly1012 maoly1012 added bug Something isn't working triage This issue is new labels Apr 22, 2024
@emmanuel-keller emmanuel-keller self-assigned this May 7, 2024
@emmanuel-keller emmanuel-keller added topic:indexing This is related to indexing and full-text search and removed triage This issue is new labels May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working topic:indexing This is related to indexing and full-text search
Projects
None yet
Development

No branches or pull requests

2 participants