Reputation: 3871
I've put an item into ElasticSearch with given index and type. How do I retrieve it?
Details:
The official documentation states this:
GET /_search
{
"query": {
"type" : {
"value" : "_doc"
}
}
}
But I don't get it. What do I do with that?
I tried to run it like this but it didn't work:
curl XGET 'http://localhost:9200/disney/_search' -d '
{
"query": {
"type" : {
"value" : "disneytype"
}
}
}'
This throws an error:
Invoke-WebRequest : A positional parameter cannot be found that accepts argument
'http://localhost:9200/disney/_search'.
At line:1 char:1
+ curl XGET 'http://localhost:9200/disney/_search' -d '
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Any ideas how to run it properly?
Upvotes: 0
Views: 166
Reputation: 3871
Another way is to run it inline like this:
curl.exe -XGET --data-binary '{ "query": { "type" : { "value" : "disneytype" }, studioid: "AAAAA" } }' -H 'content-type: application/json;' http://localhost:9200/
Upvotes: 0
Reputation: 2006
The error that you've got is not related to Elasticsearch. It is some issue with PowerShell. Replace cURL
call with Invoke-WebRequest
:
Invoke-WebRequest -Method 'POST' -Uri 'http://localhost:9200/_search' -ContentType "application/json" -Body '
{
"query": {
"type": {
"value": "disneytype"
}
}
}'
I personally prefer to use Kibana for discovering my ES indices. It is much more convenient.
Upvotes: 1