0

I've followed the guides on the elasticsearch.org site to add data and then test the Search filter.

I get back all the records though, not just on the first record.

The command I run is...

curl -XPOST 127.0.0.1:9200/bank/_search?pretty -d "{"query":{"match_all":{}},"size":1}"

The results I get are....

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 3,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "bank",
      "_type" : "accounts",
      "_id" : "AUkI69P6_5tX7kVBxTtE",
      "_score" : 1.0,
      "_source":{"index":{"_id":"1"}}
{"account_number":1,"balance":39225,"firstname":"Amber","lastname":"Duke","age":32,"gender":"M","address":"880 Holmes Lane","employer":"Pyrami","email":"amberduke@pyrami.com","city":"Brogan","state":"IL"}
{"index":{"_id":"6"}}
{"account_number":6,"balance":5686,"firstname":"Hattie","lastname":"Bond","age":36,"gender":"M","address":"671 Bristol Street","employer":"Netagy","email":"hattiebond@netagy.com","city":"Dante","state":"TN"}
{"index":{"_id":"13"}}
{"account_number":13,"balance":32838,"firstname":"Nanette","lastname":"Bates","age":28,"gender":"F","address":"789 Madison Street","employer":"Quility","email":"nanettebates@quility.com","city":"Nogal","state":"VA"}
{"index":{"_id":"18"}}
{"account_number":18,"balance":4180,"firstname":"Dale","lastname":"Adams","age":33,"gender":"M","address":"467 Hutchinson Court","employer":"Boink","email":"daleadams@boink.com","city":"Orick","state":"MD"}
{"index":{"_id":"20"}}
{"account_number":20,"balance":16418,"firstname":"Elinor","lastname":"Ratliff","age":36,"gender":"M","address":"282 Kings Place","employer":"Scentric","email":"elinorratliff@scentric.com","city":"Ribera","state":"WA"}
{"index":{"_id":"25"}}
<SNIP>

Can someone help me out please.

Thanks

note : I'm on Windows 7

note : I'm using curl-7.34.0-rtmp-ssh2-ssl-sspi-zlib-winidn-static-bin-w64

jeff porter
  • 6,560
  • 13
  • 65
  • 123
  • It kinda looks like that you indexed your bulk index API call as a single document. Look at the _source in your results and track the curly brackets. – Ellesedil Oct 14 '14 at 14:27

1 Answers1

0

After going through the response i can say that you are indeed getting only one record. The query specified above for retrieving just one record is correct. Looks like you have little confusion in the records you have indexed. There is just only one document in "bank" index. which can be concluded by the hits total size to be 1.

You have indexed all the required records containing "account_number", "balance" in just one document with just one _id field. instead you should have stored the individual records with a unique _id on each record.

could be in a possible way as below.

{
    _index: ppp
    _type: ppp_data
    _id: 53dfc0d475f493e5201065a9
    _score: 1
   _source: {
   _id: 53dfc0d475f493e5201065a9
    {"account_number":1,"balance":39225,"firstname":"Amber","lastname":"Duke","age":32,"gender":"M","address":"880 Holmes           Lane","employer":"Pyrami","email":"amberduke@pyrami.com","city":"Brogan","state":"IL"}
    {"index":{"_id":"6"}}
 }
},
{
    _index: ppp
    _type: ppp_data
    _id: 53dfc0d575f493e5201065b2
    _score: 1
   _source: {
   _id: 53dfc0d575f493e5201065b2
    {"account_number":6,"balance":5686,"firstname":"Hattie","lastname":"Bond","age":36,"gender":"M","address":"671 Bristol          Street","employer":"Netagy","email":"hattiebond@netagy.com","city":"Dante","state":"TN"}
    {"index":{"_id":"13"}}
 }
},
{
    _index: ppp
    _type: ppp_data
    _id: 53dfc0d475f493e5201065sdf
    _score: 1
   _source: {
   _id: 53dfc0d475f493e5201065sdf
    {"account_number":13,"balance":32838,"firstname":"Nanette","lastname":"Bates","age":28,"gender":"F","address":"789 Madison          Street","employer":"Quility","email":"nanettebates@quility.com","city":"Nogal","state":"VA"}
    {"index":{"_id":"18"}}
 }
}
Kumar Kailash
  • 1,385
  • 1
  • 10
  • 19