I'm running the following query against my ES instance 5.4
. My year range and postal code works great, but as soon as I add in the price or millage range, it returns zero results. Here's the cURL statement (I converted it as I'm running the ES PHP library, so my syntax may be off here).
Additionally, I've also moved the price & milage to a filter bool with no tangible results. This query was working once upon a time, but after re-importing my data, it no longer did. So, maybe it's possible I changed the type of those two fields?
In my ES instance I have a Suzuki that match this criterial.
curl -XGET 'localhost:9200/_search?pretty' -H 'Content-Type: application/json' -d'
{
"query" : {
"bool" : {
"must" : {
{"query_string" : {
"query" : "suzuki",
"fields" : {"keywords", "description", "title"}
}},
{"range" : {
"year.keyword" : {
"gte" : 2010,
"lte" : 1980
}
}},
{"range" : {
"price.keyword" : {
"gte" : 0,
"lte" : 10000
}
}},
{"range" : {
"mileage.keyword" : {
"gte" : 0,
"lte" : 100000
}
}},
{"terms" : {
"postal.keyword" : 57013
}}
}
}
},
"highlight" : {
"fields" : {
"*" : { "force_source" : "true", "fragment_size" : 250 }
}
},
"sort" : {
"price.keyword" : { "order" : "asc", "mode" : "min" }
}
}'
Here is the Suzuki ES record (some of this has been scrubbed):
_source: {
index: "",
type: "",
keywords: "2009 Suzuki Sx4 Crossover AWD Crossover 4dr 4A",
description: "2009 Suzuki SX4 Crossover AWD Crossover 4dr 4A",
title: "2009 Suzuki Sx4 Crossover AWD Crossover 4dr 4A,
postal: "57013",
price: "5600",
year: "2009",
make: "Suzuki",
model: "sx4",
mileage: "93012",
engine: "2.0L I4",
transmission: "Automatic",
trim: "AWD Crossover 4dr ",
date_added: "2017-10-01 01:48:36",
date_updated: "2017-10-01 01:48:36"
}