Skip to content
Advertisement

Elastic API doesn’t show all documents

i have elastic that i want to fetch the data from elastic with query, i have about 210 documents in the index, but when i tried to search with query match_all, the api only showing 7 documents and not all documents, is it possible to api showing all documents instead only show some documents.

The query :

192.168.20.47:9200/new/_search
{
 "query" : {
  "match_all" : {}
 }
}

The elastic API result :

{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 210,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "em-employeedata",
        "_type" : "_doc",
        "_id" : "202cb962ac59075b964b07152d234b70",
        "_score" : 1.0,
        "_source" : {
          "name" : "Gani Kartiwa Adiwisastra",
          "nip" : "123",
          "pnid" : "81dc9bdb52d04dc20036dbd8313ed055",
          "companycode" : "EBT",
          "worklocationcode" : "BT",
          "employee" : {
            "start" : "26/11/2015",
            "end" : "29/05/1453",
            "status" : "P"
          },
          "organization" : {
            "position" : "Director",
            "sector" : "Direksi",
            "department" : "Direksi",
            "division" : "Management",
            "superior" : "Director"
          }
        }
      },
      {
        "_index" : "em-employeedata",
        "_type" : "_doc",
        "_id" : "c8ffe9a587b126f152ed3d89a146b445",
        "_score" : 1.0,
        "_source" : {
          "name" : "Firmansyah",
          "nip" : "124",
          "pnid" : "9996535e07258a7bbfd8b132435c5962",
          "companycode" : "EBT",
          "worklocationcode" : "BT",
          "employee" : {
            "start" : "21/01/2014",
            "end" : "29/05/1453",
            "status" : "P"
          },
          "organization" : {
            "position" : "BE Programmer",
            "sector" : "MAI",
            "department" : "MAI",
            "division" : "MAI",
            "superior" : "Be Programmer"
          }
        }
      },
      {
        "_index" : "em-employeedata",
        "_type" : "_doc",
        "_id" : "069059b7ef840f0c74a814ec9237b6ec",
        "_score" : 1.0,
        "_source" : {
          "name" : "Erna Tri Rahayu",
          "nip" : "126",
          "pnid" : "a9eb812238f753132652ae09963a05e9",
          "companycode" : "EBT",
          "worklocationcode" : "Sudirman",
          "employee" : {
            "start" : "21/01/2014",
            "end" : "29/05/1453",
            "status" : "P"
          },
          "organization" : {
            "position" : "Finance Officer",
            "sector" : "Finance & Accounting",
            "department" : "Finance & Accounting",
            "division" : "Finance & Accounting",
            "superior" : "Finance Officer"
          }
        }
      },
      {
        "_index" : "em-employeedata",
        "_type" : "_doc",
        "_id" : "ec5decca5ed3d6b8079e2e7e7bacc9f2",
        "_score" : 1.0,
        "_source" : {
          "name" : "Sukidi",
          "nip" : "127",
          "pnid" : "d38901788c533e8286cb6400b40b386d",
          "companycode" : "EBT",
          "worklocationcode" : "Sudirman",
          "employee" : {
            "start" : "21/01/2014",
            "end" : "29/05/1453",
            "status" : "P"
          },
          "organization" : {
            "position" : "OB",
            "sector" : "GA",
            "department" : "HR & GA",
            "division" : "HR & GA",
            "superior" : "Ob"
          }
        }
      },
      {
        "_index" : "em-employeedata",
        "_type" : "_doc",
        "_id" : "76dc611d6ebaafc66cc0879c71b5db5c",
        "_score" : 1.0,
        "_source" : {
          "name" : "Ni Nyoman Indah Suwardani",
          "nip" : "128",
          "pnid" : "b3ba8f1bee1238a2f37603d90b58898d",
          "companycode" : "EBT",
          "worklocationcode" : "Sudirman",
          "employee" : {
            "start" : "22/09/2014",
            "end" : "29/05/1453",
            "status" : "P"
          },
          "organization" : {
            "position" : "Account  Manager",
            "sector" : "S&M Project",
            "department" : "S&M Project",
            "division" : "Sales & Marketing",
            "superior" : "Account  Manager"
          }
        }
      },
      {
        "_index" : "em-employeedata",
        "_type" : "_doc",
        "_id" : "d1f491a404d6854880943e5c3cd9ca25",
        "_score" : 1.0,
        "_source" : {
          "name" : "Sendhy Ferdiyanto",
          "nip" : "129",
          "pnid" : "a9078e8653368c9c291ae2f8b74012e7",
          "companycode" : "EBT",
          "worklocationcode" : "BT",
          "employee" : {
            "start" : "21/01/2014",
            "end" : "29/05/1453",
            "status" : "P"
          },
          "organization" : {
            "position" : "Project Support",
            "sector" : "Project Support",
            "department" : "S&M Project",
            "division" : "Sales & Marketing",
            "superior" : "Project Support"
          }
        }
      },
      {
        "_index" : "em-employeedata",
        "_type" : "_doc",
        "_id" : "9b8619251a19057cff70779273e95aa6",
        "_score" : 1.0,
        "_source" : {
          "name" : "Hendra Pratama",
          "nip" : "130",
          "pnid" : "1c65cef3dfd1e00c0b03923a1c591db4",
          "companycode" : "EBT",
          "worklocationcode" : "BT",
          "employee" : {
            "start" : "21/01/2014",
            "end" : "29/05/1453",
            "status" : "P"
          },
          "organization" : {
            "position" : "Project Support",
            "sector" : "Project Support",
            "department" : "S&M Project",
            "division" : "Sales & Marketing",
            "superior" : "Project Support"
          }
        }
      },
      {
        "_index" : "em-employeedata",
        "_type" : "_doc",
        "_id" : "1afa34a7f984eeabdbb0a7d494132ee5",
        "_score" : 1.0,
        "_source" : {
          "name" : "Detty Ayu",
          "nip" : "131",
          "pnid" : "2de5d16682c3c35007e4e92982f1a2ba",
          "companycode" : "EBT",
          "worklocationcode" : "Sudirman",
          "employee" : {
            "start" : "13/01/2015",
            "end" : "29/05/1453",
            "status" : "P"
          },
          "organization" : {
            "position" : "Corporate Secretary",
            "sector" : "PA / Sekretaris",
            "department" : "PA / Sekretaris",
            "division" : "Managemen",
            "superior" : "Corporate Secretary"
          }
        }
      },
      {
        "_index" : "em-employeedata",
        "_type" : "_doc",
        "_id" : "65ded5353c5ee48d0b7d48c591b8f430",
        "_score" : 1.0,
        "_source" : {
          "name" : "Deri Alvian",
          "nip" : "132",
          "pnid" : "e1d5be1c7f2f456670de3d53c7b54f4a",
          "companycode" : "EBT",
          "worklocationcode" : "BT",
          "employee" : {
            "start" : "21/01/2014",
            "end" : "29/05/1453",
            "status" : "P"
          },
          "organization" : {
            "position" : "Project Support",
            "sector" : "Project Support",
            "department" : "S&M Project",
            "division" : "Sales & Marketing",
            "superior" : "Project Support"
          }
        }
      },
      {
        "_index" : "em-employeedata",
        "_type" : "_doc",
        "_id" : "9fc3d7152ba9336a670e36d0ed79bc43",
        "_score" : 1.0,
        "_source" : {
          "name" : "Netty Purwanti",
          "nip" : "133",
          "pnid" : "2c89109d42178de8a367c0228f169bf8",
          "companycode" : "EBT",
          "worklocationcode" : "Sudirman",
          "employee" : {
            "start" : "04/05/2015",
            "end" : "29/05/1453",
            "status" : "P"
          },
          "organization" : {
            "position" : "Account Executive Central Government",
            "sector" : "S&M Central Government",
            "department" : "S&M Central Government",
            "division" : "Sales & Marketing",
            "superior" : "Account Executive Central Government"
          }
        }
      }
    ]
  }
}

Advertisement

Answer

It returns 10 results (not 7). This is because you didn’t specify a size.

From the docs:

By default, searches return the top 10 matching hits. To page through a larger set of results, you can use the search API’s from and size parameters. The from parameter defines the number of hits to skip, defaulting to 0. The size parameter is the maximum number of hits to return. Together, these two parameters define a page of results.

So, this is how your query would look with the maximum size of 10,000:

192.168.20.47:9200/new/_search
{
 "query" : {
  "match_all" : {}
 },
 "size" : 10000
}
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement