Comments (4)
Sorry I think I know where the problem is.
Instead of using json_decode() for transferring JSON to php array, I just use the JSON string as the ['body']
$sESSearch = '{ query...facets...}';
$aESSearchParam['index'] = $sESIndex;
$aESSearchParam['type'] = $sESType;
$aESSearchParam['body'] =$sESSearch;
$aReturnArray = $oESClient->search($aESSearchParam);
It throws no error and gives ['hits'] records so I thought it was ok to accept the JSON string directly.
After doubled checked ['hits'], and it is not correct, it actually gives all records, that means the search ['body'] is empty.
So the conclusion is json_decode($sJSONString, TRUE) is required if we use JSON string and then everything (including facets) will be working fine. Sorry for not carefully RTFM!
from elasticsearch-php.
Yep, you are correct. The client only accepts associative arrays in 99.99% of the APIs, so you have to convert it with json_decode()
first. The only place that accepts a string for the body is the Bulk API.
That said, I agree that the client should throw an error in this particular case...it should have raised an exception saying that strings are not valid. I'll patch that up today. Thanks!
(And no worries about not reading the documentation...they are very sparse so far! A lot of work left to do)
from elasticsearch-php.
Cool, throwing an error should be helpful. Thanks and thanks for this nice PHP client.
from elasticsearch-php.
Heya @hellovic, I looked into this deeper and your first intuition (body could accept a JSON string) was correct: there is a bug in the Search endpoint. It was trying to stuff string bodies into the 'q' URI parameter, which is incorrect.
Thanks for the bug report, and sorry for the incorrect explanation...I really need to have a cup of coffee before responding to issues :)
from elasticsearch-php.
Related Issues (20)
- Path in hosts configuration is ignored HOT 2
- check the index exsists ,it have a error HOT 1
- Connecting to Elasticsearch v8.x using the v7.17.x client HOT 1
- Received a 403 Forbidden error when attempting to index HOT 1
- `Response\Elasticsearch::offsetGet()` return type declaration HOT 2
- Need a new Release 6.8.3 HOT 4
- ServerError was not handled correctly. HOT 2
- Add support for Elasticsearch with Bulk API and data stream HOT 1
- How to pass specific characters password to ElasticSearch through Sulu/ArticleBundle HOT 5
- [Request feedback] Looking for feedback about the UX experience
- Calling static trait method ... is deprecated HOT 1
- Inquiries about version use HOT 2
- [Proposal] Add a mapTo(class) function for map ES|QL response into objects HOT 1
- Why Can't I update the mapping with Laravel Scout? HOT 1
- 使用PHP GET方法,不能获取到文档内容 HOT 4
- please help me change the php code from pagination from + size to search_after HOT 5
- failed to get the last sort using search_after HOT 1
- Add OpenTelemetry support HOT 1
- will elasticsearch-php pre-open the urls on the page when I visit it? HOT 3
- "Type: illegal_argument_exception Reason: "Fielddata is disabled on [pageCategory] in [elastic_web_index]. Text fields are not optimised for operations that require per-document field data like aggregations HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elasticsearch-php.