Need help with Kibana query

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

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 to get the results you're looking for:

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

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
}
]
}
}
}

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