doofinder / php-doofinder Goto Github PK
View Code? Open in Web Editor NEW๐๐ A PHP library for search and indexing in Doofinder
๐๐ A PHP library for search and indexing in Doofinder
Currently, the php exception that is thrown when the query limit is reached is:
throw new DoofinderException("Requests Limit Reached");
if an user wants to know what to do when the request limit is reached, she has to parse the exception message . It would be easier if:
in the constructor specify a "maximum waiting time" or the like
in the dleteType
method, add a boolean argument to indicate the method to wait untill the search engine is no longer busy indexing anything.
Site URL is deprecated and store id is a new param
any parameter specified in the options
argument of the query($query, $page, $options)
should be passed as a request parameter.
Hey Folks,
We have a frequent error when using your search client.
What we are doing:
$searchParams = [
'hashid' => $this->engine,
'indices' => [$this->index],
'query' => $searchKeyword,
'rpp' => 100
];
$dfClient->search($searchParams);
The searchKeyword is a sanitized user input.
The error in Search/Client, Line 177:
$this->_lastPage = ceil($total / $rpp); // Division by zero error
It looks like your client does not want to handle zero results when querying your API.
Furthermore, I'm confused why your documentation said we can give a rpp, but it's immediately overwritten here.
Any ideas how to handle that? :)
Here's a link to our issue in sentry.io:
Isses's link
Best,
Bent
Right now all exceptions from the Utils::handleErrors
method returns exceptions that extends \Exception; would it be possible to ensure that all those exceptions extends a generic exception, say DoofinderException
?
That would allow us to ensure that we properly catch everything that may fail when we call the API though the SDK.
The Management API uses deprecated functions, which can break functionallity, since "guzzlehttp/guzzle": "~7.3"
requires "guzzlehttp/psr7": "^1.7 || ^2.0"
:
https://github.com/guzzle/psr7/blob/1.7.0/src/functions.php#L318
https://github.com/guzzle/guzzle/blob/7.3.0/src/functions.php#L164
( ! ) Fatal error: Uncaught Error: Call to undefined function GuzzleHttp\Psr7\build_query() in /application/plugins/doofinder/vendor/doofinder/doofinder/src/Management/PhpClient/Api/SearchEnginesApi.php on line 1651 | ||||
---|---|---|---|---|
( ! ) Error: Call to undefined function GuzzleHttp\Psr7\build_query() in /application/plugins/doofinder/vendor/doofinder/doofinder/src/Management/PhpClient/Api/SearchEnginesApi.php on line 1651 | ||||
Call Stack | ||||
# | Time | Memory | Function | Location |
5 | 13.0628 | 11057240 | Doofinder\Management\ManagementClient->getSearchEngine( $hashid = 'xxx' ) | .../SearchengineController.php:54 |
6 | 13.0628 | 11057240 | DoofinderManagement\Api\SearchEnginesApi->searchEngineShow( $hashid = 'xxx' ) | .../ManagementClient.php:141 |
7 | 13.0628 | 11057240 | DoofinderManagement\Api\SearchEnginesApi->searchEngineShowWithHttpInfo( $hashid = 'xxx' ) | .../SearchEnginesApi.php:1401 |
8 | 13.0628 | 11057240 | DoofinderManagement\Api\SearchEnginesApi->searchEngineShowRequest( $hashid = 'xxx' ) | .../SearchEnginesApi.php:1419 |
If there is no log entry the logs()
funktion returns a tring: "[]"
https://github.com/doofinder/php-doofinder/blob/master/src/Management/SearchEngine.php#L302:
public function logs() {
$result = $this->client->managementApiCall("GET", "{$this->hashid}/logs");
return $result['response'];
}
from https://github.com/doofinder/php-doofinder/blob/master/src/Management/Client.php#L97:
$contentResponse = "[]";
$decoded = ($decoded = json_decode($contentResponse,true)) ? $decoded : $contentResponse;
var_dump($decoded);
$contentResponse = '[{"date":"2019-04-25T08:08:11.694963Z","level":"INFO","msg":"All \"product\" feeds were processed successfully. Items: 68 (87 Kb)"}]';
$decoded = ($decoded = json_decode($contentResponse, true)) ? $decoded : $contentResponse;
var_dump($decoded);
Result:
string(2) "[]" // sould be array(0)
array(1) {
[0]=>
array(3) {
["date"]=>
string(27) "2019-04-25T08:08:11.694963Z"
["level"]=>
string(4) "INFO"
["msg"]=>
string(66) "All "product" feeds were processed successfully. Items: 68 (87 Kb)"
}
}
You can get some inspiration from the JS library:
https://github.com/doofinder/js-doofinder/blob/master/src/stats.coffee
Results not return redirection value.
We have to try sending statistics without session_id and check if they are registered properly using our PHP-Doofinder library.
I have an engine with 2 indices: product and category
I need to get fixed number of products and categories, in my case 32 products and 32 categories.
Although, the current Doofinder API supports search in multiple indices, it returns variable amount of prods/cats. For example it returns 30 products and 2 categories.
Right now I have to make 2 search requests: one for products, and one for categories which is redundant and slows down the whole process.
There is no sort method while the API has it. What would be te best way to add sort option?
$res = http_build_query(array("pepe"=>"kiko", "culo"=>"pis")); // "?pepe=kiko&culo=pis"
but it turns out that the separator character can be changed. some servers have set that to "&" (only God knows why),
it also can be explicitly forced. That's the way to go.
Hello,
There is a small typo in the code, during a RequestException.
HttpClient.php : line 41.
if (($response = curl_exec($s)) === false) { $error = curl_error($s); curl_close($s); throw new RequestException('curl_error', $error); }
=>
if (($response = curl_exec($s)) === false) { $error = curl_error($s); curl_close($s); throw new RequestException($error); }
Thank you
They're missing in current implementation.
It's required for debugging when there's a generic error or to know more details of the error.
README.md says this works:
dfParam_sort = array(
array('price' => 'desc'),
array('title', 'asc')
);
But I'm doing this:
$query = $searchClient->query(
'vin',
null,
array(
'rpp' => 100,
'transformer' => 'onlyid',
'sort' => array(
array('best_price', 'desc'),
),
)
);
And I'm getting:
Fatal error: Uncaught Doofinder\Api\Search\Error: 400
If I execute this instead:
$query = $searchClient->query(
'vin',
null,
array(
'rpp' => 100,
'transformer' => 'onlyid',
'sort' => array(
array('best_price' =>'desc'),
),
)
);
everything works as expected.
Hello everyone,
I wanted to know if it's possible to have all products from a query ?
Because if I take the results from $client->query(), I only have the number of products per page.
many thanks.
EDIT: use getProperty method :)
If a client don't want to use composer, our client won't work. We have to modify our autoload.php to register management libraries.
according to: https://www.doofinder.com/support/developer/api/search-api#exclusion-parameters
Example: exclude "child" products:
$client->setExclude('group_id', ['gt' => 0]);
https://www.doofinder.com/support/developer/api/search-api#registering-clicks
i think this is missing in the Framework?
In your example there is a missing ; at the end of
define('API_KEY', 'eu1-384fdag73c7ff0a59g589xf9f4083bxb9727f9c3')
A client is requesting the PHP client v6: https://doofinder.freshdesk.com/a/tickets/80911
The client is ready but not deployed. The aim of this issue is review and test the client to check that is working correctly and can be deployed.
Branch: https://github.com/doofinder/php-doofinder/tree/BK-685
During the catalogsearch_fulltext reindex following API calls are performed:
DELETE https://eu1-api.doofinder.com/v1/{hashid}/types/{datatype}
POST https://eu1-api.doofinder.com/v1/{hashid}/types
The second request fails with an unhandled error "Bad request", it should be some named error which can be catched, not a "Bad request", like: "IndexingInProgress" or "ThrottledResponse".
Preconditions:
- sample data must be installed and indexed
Customer using v5 of https://github.com/doofinder/php-doofinder reports that cannot index through API. It is getting timeout/status 0 when calling getSearchEngines()
Affected account: [email protected]
Affected search engine: 47652605f1a06acb9bb5e597d26db100
Related support ticket https://doofinder.freshdesk.com/a/tickets/40247
After the version changes of the APIs to V6, the readme files, which document them, are outdated:
This task should review all the V6 functions in the two APIs and update the documentation.
Currency is missing in current model
When you do a updateBulkItem operation with a missing item, the response contains an error but the library parse as good result:
This is the response returned by api server:
{"errors":true,"results":[{"error":"document_missing_exception","id":"1","result":"[product_test][4f140023c50e00001a9020235ff7b4ab@product_test@c4ca4238a0b923820dcc509a6f75849b]: document missing"}]}
And this the error returned by the php library:
PHP Fatal error: Uncaught InvalidArgumentException: Invalid value for 'result', must be one of 'created', 'updated', 'deleted' in /home/antonio/Projects/php-doofinder/src/Management/PhpClient/Model/BulkResultResults.php:304
Stack trace:
#0 /home/antonio/Projects/php-doofinder/src/Management/PhpClient/ObjectSerializer.php(313): DoofinderManagement\Model\BulkResultResults->setResult()
#1 /home/antonio/Projects/php-doofinder/src/Management/PhpClient/ObjectSerializer.php(246): DoofinderManagement\ObjectSerializer::deserialize()
#2 /home/antonio/Projects/php-doofinder/src/Management/PhpClient/ObjectSerializer.php(313): DoofinderManagement\ObjectSerializer::deserialize()
#3 /home/antonio/Projects/php-doofinder/src/Management/PhpClient/Api/ItemsApi.php(4728): DoofinderManagement\ObjectSerializer::deserialize()
#4 /home/antonio/Projects/php-doofinder/src/Management/PhpClient/Api/ItemsApi.php(4667): DoofinderManagement\Api\ItemsApi->itemsTempBulkUpdateWithHttpInfo()
#5 /home/antonio/Projects/php-doofinder/src/Management/ManagementClient.php(709): DoofinderManagement\Api\ItemsApi->itemsTempBulkUpdate()
#6 /home/antonio/Projects/php-doofinder/test.php(35): Doofinder\Management\ManagementClient->updateTempBulk()
#7 {main}
thrown in /home/antonio/Projects/php-doofinder/src/Management/PhpClient/Model/BulkResultResults.php on line 304
Hy doofinder Team,
is it possible to get the facet sort indicator, when using the Search API?
For example like this:
"facets": {
"size": {
"sort": 1, //_<=_sort_indicator
"total": {
"value": 41
},
"terms": {
"sum_other_doc_count": 0,
"doc_count_error_upper_bound": 0,
"buckets": [
...
]
},
"doc_count": 76
},
"price": {
"sort": 4,
"range": {
"buckets": [
{
"stats": {
"sum": 10068.670000076294,
"min": 10.0,
"max": 765.0,
"count": 76,
"avg": 132.48250000100387
},
"key": "0.0-*",
"from": 0.0,
"doc_count": 76
}
]
},
"doc_count": 76
},
"plattform": {
"sort": 7,
"total": {
"value": 0
},
"terms": {
"sum_other_doc_count": 0,
"doc_count_error_upper_bound": 0,
"buckets": []
},
"doc_count": 76
},
"material": {
"sort": 6,
"total": {
"value": 0
},
"terms": {
"sum_other_doc_count": 0,
"doc_count_error_upper_bound": 0,
"buckets": []
},
"doc_count": 76
},
"genre": {
"sort": 8,
"total": {
"value": 0
},
"terms": {
"sum_other_doc_count": 0,
"doc_count_error_upper_bound": 0,
"buckets": []
},
"doc_count": 76
},
"g:availability_label": {
"sort": 3,
"total": {
"value": 76
},
"terms": {
"sum_other_doc_count": 0,
"doc_count_error_upper_bound": 0,
"buckets": [
...
]
},
"doc_count": 76
},
"color": {
"sort": 2,
"total": {
"value": 26
},
"terms": {
"sum_other_doc_count": 8,
"doc_count_error_upper_bound": 0,
"buckets": [
...
]
},
"doc_count": 76
},
"categories": {
"sort": 0,
"total": {
"value": 77
},
"terms": {
"sum_other_doc_count": 6,
"doc_count_error_upper_bound": 0,
"buckets": [
...
]
},
"doc_count": 76
},
"brand": {
"sort": 5,
"total": {
"value": 74
},
"terms": {
"sum_other_doc_count": 19,
"doc_count_error_upper_bound": 0,
"buckets": [
...
]
},
"doc_count": 76
}
}
Notice: Undefined offset: 1 in /var/www/html/vendor/doofinder/doofinder/src/Management/Client.php on line 45
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.