Using browser search it's working fine, but using elasticsearch-php client not working.
```
$client = ClientBuilder::create()->build();
$params = [
'index' => 'response_packets_index_v2',
'type' => 'documents',
'body' => [
'query' => [
'match' => [
'list_name' => 'number'
]
]
]
];
$results = $client->search($params);
```
{
"took":2,
"timed_out":false,
"_shards":{
"total":5,
"successful":5,
"skipped":0,
"failed":0
},
"hits":{
"total":0,
"max_score":null,
"hits":[
]
}
}
Are you connecting to the same host? Without specifying the parameters for ClientBuilder it connects to localhost.
@mhujer Yep, i am connecting same host => localhost:9200.
All data stored on localhost.
Below url working fine.
http://localhost:9200/sms_api_response_packets_index_v2/_search?pretty=true&size=156&q=workflow_id=943
@mhujer i find a difference between bulk indexing and single indexing.
so single index search working smoothly, but bulk index search not working.
@amit-sharma-dev The URL you posted is searching the sms_api_response_packets_index_v2 index, but is not specifying a doc type. Your PHP search is specifying the response_packets_index_v2 index and the documents doc type.
Can you try the PHP search against the same index as your URL query string (sms_api_response_packets_index_v2) and without a doctype?
@polyfractal i was searching with index and doc type, but not worked.
I found a solution, while doing bulk mapping and bulk creating, now it's working fine.
Actually, may be i am doing wrong, while create indexing.
for ($i = 0; $i <= $count; $i++) {
$params['body'][] = [
'index' => [
'_index' => 'response_packets_index_v5',
'_type' => 'response_packets_v5',
'routing' => 'company',
]
];
$params['body'][] = [
'my_field' => $documentData[$i]
];
}
return $client->bulk($params);
for ($i = 0; $i <= $count; $i++) {
$params['body'][] = [
'index' => [
'_index' => 'response_packets_index_v5',
'_type' => 'response_packets_v5',
'routing' => 'company',
]
];
$params['body'][] = $documentData[$i];
}
return $client->bulk($params);
So i just want to know, what is the difference between, above these two type bulk indexing.
Depends on what's inside of $documentData. The first example will nest all of $documentData[$i] inside of the 'my_field' field inside the JSON. So you probably created documents that looked like this:
{
"my_field" : {
"foo" : "bar",
"title" : "the title here",
"price" : 123
}
}
whereas the second example would put the $documentData directly at the top level, like this:
{
"foo" : "bar",
"title" : "the title here",
"price" : 123
}
Which is probably why your search wasn't working... the document field structure didn't match what the query was searching :)
@polyfractal so, i want to search below data using php syntax, can you give me some example.
{
"_index": "response_packets_index_v2",
"_type": "documents",
"_id": "0",
"_score": 1,
"_source": {
"my_field": {
"id": 1,
"workflow_id": "943",
"workflow_name": "Diwali",
"list_name": "number",
"list_id": "798",
"operator": "-",
"circle": "-",
"country": "-",
"sender_id": "MANISH",
"submit_date": "2017-11-06 14:09:56",
"dlrdatetime": "2017-11-06 14:10:06",
"split_count": 1,
"error_code": "Waiting",
"error_text": "-",
"currency_used": "0.2000",
"text_type": "text",
"error_code_status": null,
"origin_type": "1",
"api_response_id": 1,
"response": null,
"parent_id": null,
"is_test": 0,
"link": null,
"type": 2,
"message_text": "Hi This is text message",
"status": null,
"is_link_api": 0,
"winner_branch": null,
"instance_id": "724e540394481746",
"created_at": "2017-11-06 14:10:06",
"updated_at": "2017-11-06 14:10:06",
"branch_id": 0
}
}
$searchParams = [
'index' => 'response_packets_index_v2',
'type' => 'documents',
'body' => [
'query' => [
'bool' => [
'filter' => [
'range' => [
'created_at' => [
'gte' => '2017-11-06 14:09:00',
'lte' => '2017-11-06 14:12:56'
]
]
],
'must' => [
'match' => ['error_code' => 'Waiting']
]
]
]
]
];
return $client->search($searchParams);
My search has a timeout error. my version is 6.4 ...... I suspect that version compatibility is a problem.
Outdated issue. @amit-sharma-dev if this is still an issue I'll reopen it.
yes its still an issue for me , I am trying to search through about 100,000 records in an index I created, when i tried the same method but only 18,000 data it worked fine,
note : the same the data set on both ends
Most helpful comment
@amit-sharma-dev The URL you posted is searching the
sms_api_response_packets_index_v2index, but is not specifying a doc type. Your PHP search is specifying theresponse_packets_index_v2index and thedocumentsdoc type.Can you try the PHP search against the same index as your URL query string (
sms_api_response_packets_index_v2) and without a doctype?