kishan kurivella
kishan kurivella

Reputation: 599

Elastic Search Unique Records

Currently I am Working on Elastic Search, I need unique records, and my mySql Query is select practice_area_name from practiceareas

And also I tried Below through some elastic references, and my code is

"query" => array(
                "filtered" => array(
                    "query" => array("match_all" => array())
                )
            ),
            "aggs" => array(
                "practiceareas" => array(
                    "terms" => array(
                        "field" => "practice_area_name",
                        "size" => 0
                    )
                )
            )

Here practiceareas are type in my elastic index and practice_area_name is field. I Got Same Result, like below

"practice_areas":[{"practice_area_id" :"237","practice_area_name":"Anemia","vendors_count":"26","practice_area_Count":1},{"practice_area_id" :"237","practice_area_name":"Anemia","vendors_count":"26","practice_area_Count":1},{"practice_area_id" :"237","practice_area_name":"Anemia","vendors_count":"26","practice_area_Count":1}]

Duplicate results are coming.

Upvotes: 0

Views: 78

Answers (1)

chandra kanth
chandra kanth

Reputation: 26

You can get records count

by name wise

GET practice_areas/area/_search { "size": 0, "aggs" : { "Name" : { "terms" : { "field" : "practice_area_name.keyword" } } } }

see this

Upvotes: 1

Related Questions