manticoresoftware / manticoresearch-php

Official PHP client for Manticore Search
MIT License
165 stars 32 forks source link

Can i use setMachRanking? #42

Open skvarovski opened 4 years ago

skvarovski commented 4 years ago

Hello Devs Can i use Ranking for this module? Can i use Weight for field's?

in documentation not found information

sanikolaev commented 4 years ago

Hi

Unfortunately only via https://github.com/manticoresoftware/manticoresearch-php/blob/master/docs/sql.md and https://docs.manticoresearch.com/latest/html/sphinxql_reference/select_syntax.html?highlight=field_weights#option

as OPTIONS is not implemented in the JSON interface yet which the php client depends on. I'll keep this issue open until it is.

skvarovski commented 4 years ago

thanks for answer. Is there any hope of implementation when it will be possible to set weights during client initialization through setRanking()?

githubmanticore commented 4 years ago

➤ Sergey Nikolaev commented:

Can you elaborate on your use case? Why is it important to have it on the client initialization phase?

skvarovski commented 4 years ago

for example, I have the fields "brand name", "name" and "product description", "category description", and etc. I would like to select the necessary weights for these fields dynamically. just setting weights for each of the fields before the request. Previously, through sphinxApi, this was done quite simply, but here you need to enter a field and do sorting

sanikolaev commented 4 years ago

I have the fields "brand name", "name" and "product description", "category description", and etc. I would like to select the necessary weights for these fields dynamically. just setting weights for each of the fields before the request

What's interesting is whether and why you really need to be able to set field weights on CLIENT initialization phase or it's sufficient to be able to do it before EACH query. E.g. the likely reason may be that your field weights are constant and you are never going to change them, so you would like to put the to your application config or hardcode in the client initialization code and forget about them in other parts of your app. But it's a little bit in contra with "select the necessary weights for these fields dynamically".

here you need to enter a field and do sorting

Can you provide more details on "here you need to enter a field and do sorting". What exactly do you mean? Using the SQL endpoint https://github.com/manticoresoftware/manticoresearch-php/blob/master/docs/sql.md ?

skvarovski commented 4 years ago

thanks for the answer. I don’t understand yet how to put weights at the fields correctly. let's just say that I have fields about which I wrote above, when I run a search through php-api, I need to produce first of all fields that are more priority in the field of "category description" since there will be "keywords". and then further on the priority of "product name", "product description".

example of sports nutrition products: 1) BSN / Sуnta-6 and Isolate / (protein category) 2) Bombbar / protein cookies / (category cookies)

when searching for "protein" cookies are now in the top. Previously, I remember the opportunity to prioritize the fields when ranking, how to do this with weights - I don’t understand, it’s more likely not to be possible.

upd. I find my old code. i use API ->SetFieldWeights(array ( 'field1' => 50, 'field2' => 40, 'field3' => 10, 'field4' => 5, ));

your project will be release his implement? or i can use native php client?

sanikolaev commented 4 years ago

I don’t understand yet how to put weights at the fields correctly

Here's how it can be done via SQL:

MySQL [(none)]> create table t(field1 text, field2 text, field3 text, field4 text);
MySQL [(none)]> insert into t(field1, field2, field3) values('BSN','Snta-6 and Isolate','protein'),('Bombbar','protein cookies','cookies');
MySQL [(none)]> select * from t where match('protein');
+---------------------+---------+--------------------+---------+--------+
| id                  | field1  | field2             | field3  | field4 |
+---------------------+---------+--------------------+---------+--------+
| 1657913280053641218 | BSN     | Snta-6 and Isolate | protein |        |
| 1657913280053641219 | Bombbar | protein cookies    | cookies |        |
+---------------------+---------+--------------------+---------+--------+
MySQL [(none)]> select * from t where match('protein') option field_weights=(field2=10,field3=1);
+---------------------+---------+--------------------+---------+--------+
| id                  | field1  | field2             | field3  | field4 |
+---------------------+---------+--------------------+---------+--------+
| 1657913280053641219 | Bombbar | protein cookies    | cookies |        |
| 1657913280053641218 | BSN     | Snta-6 and Isolate | protein |        |
+---------------------+---------+--------------------+---------+--------+

The functionality option field_weights is not available in the new php client, so the only way now to execute the above is by using the sql method

skvarovski commented 4 years ago

I express my gratitude for the detailed answer, I will try to use sql. I will rewrite my service. Is there any hope of future API support in the new client?

sanikolaev commented 4 years ago

Is there any hope of future API support in the new client?

Sure, as soon as we add support for the OPTIONS in the JSON interface we'll add it to the client. I'm keeping this issue open until then.

skvarovski commented 3 years ago

Dear devs i use SQL mode with field_weight ... and now i need FACET , but php client say "multiple queries not supported"

my sql = "SELECT * FROM shop where MATCH('".$text."') limit 1000 option field_weights=(name_tov=40,brand_name=60,category_keywords=80,category_description=20,product_description=10) FACET category_id;"

it's time to use JSON API interface ?

sanikolaev commented 3 years ago

and now i need FACET

@skvarovski Hi. Is https://github.com/manticoresoftware/manticoresearch-php/blob/master/docs/searchclass.md#facet not working for you?

skvarovski commented 3 years ago

facet working after update manticore engine from 3.4 to 3.5.4 version. but php client not support OPTION for field_weights set? may be i can send raw sql ?

skvarovski commented 3 years ago

my temporary solution for use Field_Ranking and FACET is sphinx client (yii2-sphinx)... its work for multiple result (data & facet)

sanikolaev commented 3 years ago

may be i can send raw sql ?

Yes, you can - https://github.com/manticoresoftware/manticoresearch-php/blob/master/docs/sql.md

I'm closing this issue as there seems to be no further work required. Reopen it or create another one if you find more issues with the client.

sanikolaev commented 2 years ago

I'm reopening it since it was closed by mistake since the original problem was that the php client can't set field weights. It's still so. Let it be open until it's fixed.