Hi there,
Unfortunately I don't have a set of CURL steps available at the moment so I
will do my best to succinctly describe my situation.
We currently have two mappings, one for beneficiaries, the other for
campaigns.
When searching for a term, such as "heart", I am trying to return all
results that match this term from both mappings, and if the potential
result is from the campaigns mapping, also ensure that the campaign is
'active' (current date is between start & end date of campaign).
This is query I have constructed:
{
"min_score": 0.99,
"from": 0,
"size": 9,
"query": {
"query_string": {
"query": "heart",
"default_operator": "OR",
"fields": [
"beneficiaries.name.search",
"beneficiaries.categories.search^2",
"campaigns.beneficiary.search",
"campaigns.categories.search^2"
]
}
},
"filter": {
"and": [
{
"terms": {
"_type": [
"beneficiaries",
"campaigns"
]
}
},
{
"range": {
"start_date.value": {
"lte": "now",
"gte": "19700101T100000Z"
}
}
},
{
"range": {
"end_date.value": {
"lte": "20150429T161301Z",
"gte": "now"
}
}
}
]
}
}
This query "works", but fails to return any results from the beneficiaries
mapping.
I think where this query is going wrong is it trying to match the range
even though those fields don't exist on the beneficiaries mapping.
Is there some sort of way to require the result to match these fields
(start_date, end_date range) if they exist (ie. _type = "campaigns") and
ignore them otherwise?
Thanks for any help!
Cheers,
Brendan
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.