# Need help with Kibana query

**URL:** <https://discuss.elastic.co/t/need-help-with-kibana-query/178340>\
**Category:** Kibana\
**Created:** [April 25, 2019, 1:42am UTC](https://discuss.elastic.co/t/need-help-with-kibana-query/178340 "2019-04-25T01:42:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![deshpamit](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@deshpamit](https://discuss.elastic.co/u/deshpamit)\
**Post date:** [April 25, 2019, 1:42am UTC](https://discuss.elastic.co/t/need-help-with-kibana-query/178340/1 "2019-04-25T01:42:43Z")

</div>

I have multiple documents as  
"\_source": {  
"vin": "SALSK25448A121736",  
"make": "Land Rover",  
"model": "Range Rover Sport",  
"trim": "HSE",  
"year": 2008,  
"body\_style": "SUV",  
"city": "Hollywood",  
"drive\_type": "4WD",  
"engine": "8 Cyl",.....  
"\_source": {  
"vin": "SALSK25448A121736",  
"make": "Land Rover",  
"model": "Range Rover",  
"trim": "HSE",  
"year": 2009,  
"body\_style": "SUV",  
"city": "Hollywood",  
"drive\_type": "2WD",  
"engine": "6 Cyl",....  
"\_source": {  
"vin": "SALSK25448A121736",  
"make": "Land Rover",  
"model": "Range Rover",  
"trim": "HSE",  
"year": 2009,  
"body\_style": "SUV",  
"city": "Hollywood",  
"drive\_type": "2WD",  
"engine": "4 Cyl",....  
And I want to fetch records matching say field "engine": "6 Cyl" & "8 Cyl" How can I do that?

I used {  
"match" : {  
"engine" : {  
"query" : "4 Cyl ,8 Cyl",  
"operator" : "OR",  
"prefix\_length" : 0,  
"max\_expansions" : 50,  
"fuzzy\_transpositions" : true,  
"lenient" : false,  
"zero\_terms\_query" : "NONE",  
"boost" : 1.0  
}  
} it returns all 3 documents v/s 2

---

<div class="post-metadata">

**Author:** ![Larry\_Gregory](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/larry_gregory/32/34969_2.png) [@Larry\_Gregory](https://discuss.elastic.co/u/Larry_Gregory)\
**Post date:** [April 25, 2019, 11:43am UTC](https://discuss.elastic.co/t/need-help-with-kibana-query/178340/2 "2019-04-25T11:43:38Z")

</div>

Hey @deshpamit,

If your `engine` property is a keyword type (or if it's also indexed as a keyword via `engine.keyword`), then you can use a [Terms Query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html) to get the results you're looking for:

```auto
POST deshpamit/_search
{
  "query": {
    "terms": {
      "engine.keyword": ["4 Cyl", "8 Cyl"]
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![deshpamit](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@deshpamit](https://discuss.elastic.co/u/deshpamit)\
**Post date:** [May 7, 2019, 3:47am UTC](https://discuss.elastic.co/t/need-help-with-kibana-query/178340/3 "2019-05-07T03:47:12Z")

</div>

Thanks alot.

Now on similar lines I am trying to get unique values from documents which has array of strings as follows I am trying to use aggs but get document errors

Any help?

"details": [  
"4-Wheel Disc Brakes",  
"AM/FM",  
"Air Conditioning",  
"Anti-Lock Brakes",  
"Anti-Theft System",  
"CD (Single Disc)",  
"Child Safety Locks",  
"Cruise Control",  
"Driver Adjustable Lumbar",  
"Dual-Zone Climate Control",  
"Fog Lights",  
"Front Airbags (Driver)",  
"Front Airbags (Passenger)",  
"High Intensity Discharge Headlights",  
"Integrated Garage Door Opener",  
"Keyless Entry",  
"Leather Steering Wheel",  
"Leather Trimmed Interior",  
"Navigation System",  
"Parking Sensors",  
"Power Locks",  
"Power Mirrors",  
"Power Outlet",  
"Power Seat (Dual)",  
"Power Steering",  
"Power Sun/Moonroof",  
"Power Windows",  
"Premium Sound System",  
"Rain-Sensing Wipers",  
"Rear Head Airbags",  
"Rear Side Airbags",  
"Rear Window Defroster",  
"Rear-View Camera",  
"Side Airbag",  
"Side Airbags",  
"Steering Wheel Controls",  
"Tire Pressure Monitoring System",  
"Towing Package",  
"Traction Control",  
"Wood Trimmed Interior"  
],

{  
"size": 0,  
"aggs": {  
"topics": {  
"terms": {  
"field": "details.keyword"  
}  
}  
}  
}

output  
{  
"took": 2,  
"timed\_out": false,  
"\_shards": {  
"total": 10,  
"successful": 10,  
"skipped": 0,  
"failed": 0  
},  
"hits": {  
"total": 3982581,  
"max\_score": 0,  
"hits":   
},  
"aggregations": {  
"topics": {  
"doc\_count\_error\_upper\_bound": 2481748,  
"sum\_other\_doc\_count": 215047227,  
"buckets": [  
{  
"key": "Air Conditioning",  
"doc\_count": 3502476  
},  
{  
"key": "Anti-Lock Brakes",  
"doc\_count": 3430251  
},  
{  
"key": "AM/FM",  
"doc\_count": 3374604  
},  
{  
"key": "Adjustable Steering Wheel",  
"doc\_count": 3337018  
},  
{  
"key": "Power Mirrors",  
"doc\_count": 3334816  
},  
{  
"key": "Power Steering",  
"doc\_count": 3238098  
},  
{  
"key": "Front Airbags (Passenger)",  
"doc\_count": 3204755  
},  
{  
"key": "Traction Control",  
"doc\_count": 3158937  
},  
{  
"key": "Stability Control",  
"doc\_count": 3149847  
},  
{  
"key": "Steering Wheel Controls",  
"doc\_count": 3126378  
}  
]  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 4, 2019, 3:47am UTC](https://discuss.elastic.co/t/need-help-with-kibana-query/178340/4 "2019-06-04T03:47:13Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
