Elasticsearch-PHP => query issue with parameter size & from [FIX]


(Dom Sie) #1

Hi :slight_smile:
I have a issue with my elasticsearch query [use elasticsearch-php 2.0]:

			$client = new Elasticsearch\Client();

			$suchString = addslashes(utf8_decode($_POST['suche']));
			$params = [
				'index' => 'jdbc',
				'type' => 'jdbc',
				'body' => [
					'sort' => [
						'_id' => [ 'order' => 'asc' ]
					],
				'from' => 0,
				'size' => 100,
					'query' => [
						'match' => [
							'text_full' => $suchString
						]
					]
				],
				
			];
			

			$results = $client->search($params);

The results looks great; but ES only return 10 documents.
I know that by default ElasticSearch returns only 10 documents from all the ones that were found.
And i know that i can modify this with the size and from parameters -> but it dit not work for me :confused:

I hope that someone here can correct my query...

thanks


(Mark Harwood) #2

Are you sure there's more than 10 results for that query?
What happens if you set "from" to 11?


(Dom Sie) #3

Hi,

yes i am sure; the query-result have 861results ...

When i set 'from' to '11' the query result depend on 10 results; starts with 11...so the from parameter works :slight_smile:
but i dont understand why the size parameter do no work...


(Dom Sie) #4

Embarrassing , was my mistake .
Forget to change the for-loop from
for ($i = 0; $i <= 9; $i++) {
to
for ($i = 0; $i <= $limit; $i++) {

SORRY xD Thanks for your answer...


(Mark Harwood) #5

No worries. Sometimes a bug is just waiting for an audience....


(system) #6