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

full text query macth not work #139

Open
foolishlittlefox opened this issue Nov 29, 2023 · 4 comments
Open

full text query macth not work #139

foolishlittlefox opened this issue Nov 29, 2023 · 4 comments
Assignees

Comments

@foolishlittlefox
Copy link

foolishlittlefox commented Nov 29, 2023

_ = db.Use(sharding.Register(sharding.Config{
		ShardingKey:         "ymd",
		NumberOfShards:      100,
		PrimaryKeyGenerator: sharding.PKCustom,
		ShardingAlgorithm: func(columnValue any) (suffix string, err error) {
			parentId := cast.ToInt(columnValue)
			suffix = fmt.Sprintf("_%v", parentId)
			return
		},
		PrimaryKeyGeneratorFn: func(tableIdx int64) int64 {
			return 0
		},
		// This case for show up give notifications, audit_logs table use same sharding rule.
	}, ChatMsg{}))

qb.Where(fmt.Sprintf("(MATCH(body) AGAINST('%s'))", req.Key))

can not fond table

@foolishlittlefox foolishlittlefox changed the title full text query macth now work full text query macth not work Nov 29, 2023
@huacnlee
Copy link
Collaborator

All query must include the sharding key.

You have used ymd column as the sharding key, but there is not include in there where conditions.

@foolishlittlefox
Copy link
Author

foolishlittlefox commented Nov 29, 2023

This is the complete sql statement

SELECT * FROM t_chat_msg WHERE ymd = 202311 AND to = '1025359' AND (MATCH(body) AGAINST('' IN BOOLEAN MODE)) LIMIT 20

I found that it should be caused by the sqlparser package not being able to correctly parse SQL statements.

@foolishlittlefox
Copy link
Author

It should be that this statement was not parsed successfully.
expr, err := sqlparser.NewParser(strings.NewReader(query)).ParseStatement()

@huacnlee
Copy link
Collaborator

@hyperphoton 这个应该是 SQLParser 解析不了

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

3 participants