I am using Firebase Flashlight to query my Firebase database.
Here is how my data is structured in Firebase:
posts: {
id: {
"address": "",
"id": "",
"name": "",
"review": "",
"summary": "",
}, id: {...}
},
users: {
uid: {
"username": "",
"name": "",
}, uid: {...}
}
And this is the how I have set up my config.js in the Flashlight Node app:
exports.paths = [
{
path: "users",
index: "firebase",
type: "user",
fields: ["username", "name"]
},{
path: "posts",
index: "firebase",
type: "post",
fields: ["id","name","summary","review", "address"]
}
];
I can easily search for a user by sending a simple query string that will search the usernames and names of users and return the uid of that user.
I want to be able to loop through an array of post ids (basically just a loop of queries), and see if any of the other fields (address, name, review, summary) match a specified keyword, with wildcard too.
So the search must match the post id, and must match the keyword to address OR name OR review OR summary.
This is the query I have tried, but I do not know how to do the ORs:
var query = {
'query': {
'bool': {
'must': [
{'match': {'name': 'duck'}},
{'match': {'review': 'duck'}},
{'match': {'summary': 'duck'}},
{'match': {'address': 'duck'}},
{'match': {'id': '-K1kiCqGWfM-29pi9wdC'}}
]
}
}
};
How can I form a query that will check if the id matches the id field and the keyword matches any of the other fields?