appbaseio / appbaseio/reactivesearch
Best way to query two fields of nested data and render results
- Vorherrschende Sprache
- JavaScript
- Sterne
- 4.9k
- Forks
- 478
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
**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:
```json
{
"name":"John Doe",
"apps" :[
{
"name": "Call of Duty",
"installed_at":
},
{
"name": "Super Mario",
"installed_at" :
},
]
}
```
Code on Reactjs
```
/>
```
**Describe the solution you'd like**
When it is making the query for search, it is making two separate `must`s 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
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.