AndyB
December 7, 2015, 6:29pm
1
Hello, I have been able to use the following test script without any problems using ElasticSearch v1.x. But now that I have updated to ElasticSearch 2.1 it no longer works. I know the index is correct as I have another application that works fine, but this basic cURL is not.
<?php
$data_string = '{
"from" : 0, "size" : 100,
"sort" : [
{ "date" : {"order" : "desc"} }
],
"query": {
"match" : {
"thread.title" : {
"query" : "pictures"
}
}
}
}';
$ch = curl_init('http://localhost:9200/xenforo150/_search?pretty=true');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string );
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$result = curl_exec($ch);
echo $result;
AndyB
December 7, 2015, 7:03pm
2
The output of $result is:
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
dadoonet
(David Pilato)
December 7, 2015, 7:15pm
3
I can't really see what is wrong here...
Can you give what is the output of GET xenforo150/_search
?
AndyB
December 7, 2015, 7:28pm
4
The following command executed from the terminal works properly:
curl -XGET 'http://localhost:9200/xenforo150/_search?q=title:pictures '
I get the the data I'm expecting to get in post number 1.
AndyB
December 7, 2015, 7:31pm
5
I changed the script by removing the thread.title to just title and now the script works.
AndyB
December 7, 2015, 7:35pm
6
This is the mapping, why can't I use thread.title as I was able to with ElasticSearch v1.x.
[root@ss0084 ~]# curl -XGET 'http://localhost:9200/xenforo150/_mapping?pretty=true'
{
"xenforo150" : {
"mappings" : {
"post" : {
"properties" : {
"date" : {
"type" : "long"
},
"discussion_id" : {
"type" : "long"
},
"message" : {
"type" : "string"
},
"node" : {
"type" : "long"
},
"thread" : {
"type" : "long"
},
"title" : {
"type" : "string"
},
"user" : {
"type" : "long"
}
}
},
"thread" : {
"properties" : {
"date" : {
"type" : "long"
},
"discussion_id" : {
"type" : "long"
},
"message" : {
"type" : "string"
},
"node" : {
"type" : "long"
},
"thread" : {
"type" : "long"
},
"title" : {
"type" : "string"
},
"user" : {
"type" : "long"
}
}
}
}
}
}
dadoonet
(David Pilato)
December 7, 2015, 7:53pm
7