Best way to query two fields of nested data and render results
Affected Projects React
Is your feature request related to a problem? Please describe. I have an index with nested data (list of objects), i want to query on two the nested fields a) title(keyword) 2) installed at(date time range). What is the best way to achieve that when i'm using two components. Example index data:
{
"name":"John Doe",
"apps" :[
{
"name": "Call of Duty",
"installed_at": <some date stamp>
},
{
"name": "Super Mario",
"installed_at" : <some date stamp>
},
]
}
Code on Reactjs
<MultiList
title="App Name"
componentId="AppNameFilter"
dataField="apps.name.keyword"
nestedField={"apps"}
size={100}
URLParams={true}
/>
<DateRange
title="App installed at"
componentId="AppInstalledFilter"
dataField="apps.installed_at"
nestedField={"apps"}
placeholder={{
start: 'Start Date',
end: 'End Date',
}}
URLParams={true}
/>
<ReactiveList
componentId="SearchResult"
// dataField="name"
size={12}
pagination
URLParams
react={{
and: ["AppNameFilter","AppInstalledFilter"]
}}
... render etc
/>
/>
Describe the solution you'd like
When it is making the query for search, it is making two separate musts for app.name and app.installed_at. But I want
Looking for making a search taking inputs name and installed_at from two different components and make a query like this
GET /theindex/_search?size=500&from=0
{
"query": {
"nested": {
"path": "apps",
"query": {
"bool": {
"must": [
{ "match": { "apps.name": "RandomeApp" }},
{ "range": { "apps.installed_at":{"gte":1590949800000,"lte":1591813800000}}}
]
}
}
}
}
}
What is the best way to achieve this
Describe alternatives you've considered None
Additional context None
Is there any workaround for this until an enhancement comes?