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

Can't index name be written in Hump? #711

Closed
cranebn opened this issue Feb 15, 2022 · 10 comments
Closed

Can't index name be written in Hump? #711

cranebn opened this issue Feb 15, 2022 · 10 comments
Labels
waiting Waiting for the original poster (in most cases) or something else

Comments

@cranebn
Copy link

cranebn commented Feb 15, 2022

I created an index with a hump like goodsSearch.
When I use PHP, I set the index name in the parameter,
The result returns a prompt: "unknown local index (ES) 'goodssearch' in search request"

@sanikolaev
Copy link
Collaborator

I created an index with a hump like goodsSearch

In general index names in Manticore are lowercased, the only exception is a plain index. I assume you use a plain index. As said in the docs https://manual.manticoresearch.com/Creating_an_index/Local_indexes#Defining-index-schema-in-config-(Plain-mode)

Index names are case sensitive in this mode.

but when you use Manticore PHP client (which is my 2nd assumption) it uses HTTP JSON protocol which lowercases index name in your request.

@sanikolaev sanikolaev added the waiting Waiting for the original poster (in most cases) or something else label Feb 16, 2022
@cranebn
Copy link
Author

cranebn commented Feb 17, 2022

OK, thank you for your answer.

There are two other questions, please.
I use an external database (MySQL) and a common index. Several problems have been found (maybe I haven't configured it well)

  1. PHP client, highlight is empty, no matter whether I configure SQL in source or not_ field_ string
  2. I want to use field_ Weights configures field weights, but I added options to the body, which didn't work.

The body I submitted is as follows:
$params = [ 'body' => [ 'index' => 'goods_search', "profile"=>true, 'limit'=>$limit, 'offset'=>($page - 1)*$limit, 'max_matches'=>3000, 'query'=>[ //'query_string'=>$key, 'match'=>['_all'=>$key], ], //'highlight'=>(object)null, 'options' => [ 'ranker' =>'sph04', 'field_weights'=>'(title=10, body=3)', ] ] ]; $res = $client->search($params);

@sanikolaev
Copy link
Collaborator

@cranebn
Copy link
Author

cranebn commented Feb 17, 2022

thank you for your help. I have realized field_ Weights configuration, but when running through SQL, highlight is still empty.
I read it in the official website document
all use built-in document storage for retrieving original field contents (enabled by default)

Do I need to configure any parameters?
My profile:
sql_query = select id,title,content,updateTime from body_goods where id>=$start and id<=$end
sql_attr_uint = updateTime

My SQL:
SELECT *,HIGHLIGHT() as highlight FROM goods_search where MATCH('key') limit 0,20 OPTION ranker=sph04, max_matches=3000, field_weights=(title=10, content=3)

I'm very sorry to trouble you again

@sanikolaev
Copy link
Collaborator

I can't reproduce it:

mysql> drop table if exists goods_search; create table goods_search(title text, content text); insert into goods_search(title) values('smth key smth'); SELECT *,HIGHLIGHT() as highlight FROM goods_search where MATCH('key') limit 0,20 OPTION ranker=sph04, max_matches=3000, field_weights=(title=10, content=3);
Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

+---------------------+---------------+---------+----------------------+
| id                  | title         | content | highlight            |
+---------------------+---------------+---------+----------------------+
| 1514688521527361537 | smth key smth |         | smth <b>key</b> smth |
+---------------------+---------------+---------+----------------------+
1 row in set (0.01 sec)

Provide more details on how to reproduce the issue.

@tomatolog
Copy link
Contributor

highlight works with docstore that is why you need to index your fields into docstore too as full-text fields could be used only for matching but can not be used for fetching text information back to client

@cranebn
Copy link
Author

cranebn commented Feb 18, 2022

Data: external MySQL data
Conf configuration file:

{
	type            = mysql
	sql_host        = 127.0.0.1
	sql_user        = user
	sql_pass        = password
	sql_db          = user
	sql_port        = 3306
	sql_query_pre   = SET NAMES utf8 
	sql_query_pre  = REPLACE INTO sph_counter SELECT 1, MAX(updateTime) FROM body_goods
	sql_query_range = SELECT MIN(id),MAX(id) FROM body_goods
	sql_range_step  = 5000
	sql_query       = select id,title,content,updateTime from body_goods where id>=$start and id<=$end
	sql_attr_uint   = updateTime
}

index goods_search
{
	source          = goods
	path            = /var/manticore/goods/main
    charset_table   = non_cjk,chinese
	morphology      = icu_chinese
	stopwords       = zh
	expand_keywords=1
}

MySQL running result:

mysql> SELECT *,HIGHLIGHT() as highlight FROM goods_search where MATCH('goods') limit 0,20 OPTION ranker=sph04, max_matches=3000, field_weights=(title=10, content=3);
+------+------------+-----------+
| id   | updatetime | highlight |
+------+------------+-----------+
|  110 | 1645086598 |           |
+------+------------+-----------+
1 row in set (0.00 sec)

mysql> SELECT *,HIGHLIGHT() as highlight FROM goods_search where MATCH('公路') limit 0,20 OPTION ranker=sph04, max_matches=3000, field_weights=(title=10, content=3);
+------+------------+-----------+
| id   | updatetime | highlight |
+------+------------+-----------+
|   57 | 1643289680 |           |
|    3 | 1645085512 |           |
|   70 | 1643644014 |           |
|   71 | 1643867569 |           |
|   77 | 1643976149 |           |
|   56 | 1643206324 |           |
|  107 | 1644998756 |           |
+------+------------+-----------+
7 rows in set (0.00 sec)

PS: the data contains Chinese data and English data, but I have tested both data without highlight. I don't know what's wrong with me...
PPS: I'm sorry we can't provide data. You can generate some data to test, pure English data and Chinese data

@cranebn
Copy link
Author

cranebn commented Feb 18, 2022

highlight works with docstore that is why you need to index your fields into docstore too as full-text fields could be used only for matching but can not be used for fetching text information back to client

Both the title and content field types are text.

+------------+--------+------------+
| Field      | Type   | Properties |
+------------+--------+------------+
| id         | bigint |            |
| title      | text   | indexed    |
| content    | text   | indexed    |
| updatetime | uint   |            |
+------------+--------+------------+

@sanikolaev
Copy link
Collaborator

Both the title and content field types are text.

Since the index is plain it's not enough. Type text has properties indexed and stored. In your case it's only indexed.

You need to add:

stored_fields = title, content

to the index. More info here https://manual.manticoresearch.com/Creating_an_index/Local_indexes/Plain_and_real-time_index_settings#stored_fields

@cranebn
Copy link
Author

cranebn commented Feb 18, 2022

I see. Thank you very much for your answer.
Support manticoresearch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting Waiting for the original poster (in most cases) or something else
Projects
None yet
Development

No branches or pull requests

3 participants